NoMethodError, help on fixing it
#1
I have a script that mimics psn/xbl Achievements. When trying to implement it to my game, i get a NoMethodError:

[Image: error.jpg]

The method that causes this error is the part that will show an alert when the player gets a new achievement. (Here's that part of the code that produces the error, exact line of error: if $game_system.queue.size > 0 && @frame < 1)

Code:
#===============================================================================
# Graphics
#-------------------------------------------------------------------------------
# **added method to control and draw all queued achievements.
#===============================================================================
module Graphics
  class << self
    alias gg_upd_awards_queue_lat update
  end
  def self.update
    @frame = 0 if @frame == nil
if $game_system.queue.size > 0 && @frame < 1
      award = Awards::Award[$game_system.queue[0]]
      if award != nil
        @sprite = Sprite_Award.new(award)
        @frame = Awards::Popup_Time
        Audio.se_play("Audio/SE/#{Awards::Popup_Sound[0]}",
          Awards::Popup_Sound[1], Awards::Popup_Sound[2])
      end
    end
    if @frame > 0
      @frame -= 1
      if @frame < 1
        @sprite.dispose
        $game_system.queue.shift
      end
    end
    gg_upd_awards_queue_lat
  end
end

If i understand it right, this adds a method to module graphics to let it draw achievements. I have other scripts that possibly make edits to Graphics Module as well, so i think that causes the error? If so, is it possible to edit this script to fix the error without changing other scripts? Because then a tidal wave of other errors might occure.

Full script here:

http://www.text-upload.com/read.php?id=102621&c=7454606

Help is appreciated!
Reply }
#2
try putting this at the beginning of the script:
Code:
#===============================================================================
# Game_System
#-------------------------------------------------------------------------------
# **modded to keep track of queued and obtained achievements.
#===============================================================================
class Game_System
attr_accessor :awards
attr_accessor :queue
alias gg_init_awards_sys_lat initialize
def initialize
@awards = []
@queue = []
gg_init_awards_sys_lat
end
def gain_award(id)
return if @awards.include?(id) || Awards::Award[id] == nil
if Awards::Track_Score
$game_variables[Awards::Variable_Id] += Awards::Award[id][3]
end
@awards.push(id)
@queue.push(id)
end
end

Might fix it
Valdred
Tech Administrator of Save-Point
Reply }
#3
Hmm, didn't fix it. But I got a golden tip: it's because my splashscreen script calls the graphics module before this script. With this info I think i can solve this myself.
Reply }
#4
@gRaViJa
$game_system is initialized only after the new game/load game. so you can simply check if it's different from nil.

if $game_system != nil and $game_system.queue.size > 0 and @frame < 1
Reply }




Users browsing this thread: 3 Guest(s)