#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2008
    Posts
    2
    Rep Power
    0

    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!!!!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2004
    Location
    Constant Limbo
    Posts
    989
    Rep Power
    363
    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.
    Code:
    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
    True happiness is not getting what you want, it's wanting what you've already got.

    My Blog
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2008
    Posts
    2
    Rep Power
    0
    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
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2004
    Location
    Constant Limbo
    Posts
    989
    Rep Power
    363
    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).
    True happiness is not getting what you want, it's wanting what you've already got.

    My Blog

IMN logo majestic logo threadwatch logo seochat tools logo