Helpful Information
 
 
Category: Ruby Programming
RPG Maker script probelm... HELP!!!!!

Okay, I am getting this error:
"undefined method `*' for nil:NilCLass"

this is the script it is pointing towards:
$game_system.killed.push([sprite.character, time*40])

why is it saying this... and how can I fix it??? Please HELP!!!!

the time variable is nil. Trying to multiply that with 40 is giving you your error. Since we cant see where time is assigned (or, in this case, not assigned) we arent going to be able to provide you with much assistance.
irb(main):001:0> time = nil
=> nil
irb(main):002:0> time * 40
NoMethodError: undefined method `*' for nil:NilClass
from (irb):2
irb(main):003:0>How are you assigning time

I have the respawn time as 5... if that helps, here is the script using to assign time...

time = sprite.character.respawn_point.respawn_time

That call (respawn_time) is returning nil. That or time is being modified elsewhere before the error point. Either way, you should get a stack trace when things fail. That can be used to find the culprit. You can also try to catch the exception yourself and do something meaningful (be it look for a cause or simply provide default value to use in that case).










privacy (GDPR)