Glitchfinder
Staff
I've been trying to create a timer script that I can call using other scripts, but I've hit a little speedbump. It keeps giving me the error
Now, I'm using RMXP, and I've never been able to figure out what could cause this error, when everything should work just fine. Here's my script:
Also, here's how I'm calling this code:
What I'm trying to do is to create a timer script that I can call from another script, hopefully multiple times within the same script. Anyone have any ideas on how I can fix this? Thanks!
Script 'Wait' line 19: NoMethodError occurred.
undefined method '+' for nil:NilClass
Now, I'm using RMXP, and I've never been able to figure out what could cause this error, when everything should work just fine. Here's my script:
Code:
class Timer
def main
@wait = 0
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
end
def update
if @wait != $totalwait
@wait += 1
elsif @wait == $totalwait
$wait = @wait
end
end
end
Also, here's how I'm calling this code:
Code:
if @variable1 == 0
$totalwait = 400
@wait = Timer.new
end
@wait.update
if $wait == $totalwait
# continue code
end
@variable1 = 1
What I'm trying to do is to create a timer script that I can call from another script, hopefully multiple times within the same script. Anyone have any ideas on how I can fix this? Thanks!