Yami - Retain State on Death - NoMethodError

Jatopian

Veteran
Veteran
Joined
Jul 5, 2015
Messages
53
Reaction score
15
First Language
English
Primarily Uses
When using Yami's "Retain State on Death" script (found here) the game seems to crash when a character dies while having a state that should not be retained on death. (In the attached example this state is MP Regen.)

The error message box says "Retain State on Death:87:in `block in die': undefined method `push' for nil:NilClass, NoMethodError"

I have attached a zip of only the data files of the example project, as recommended in this pinned thread.
 

Attachments

MobiusXVI

Game Maker
Veteran
Joined
Mar 20, 2013
Messages
383
Reaction score
91
First Language
English
Primarily Uses
There seems to be some odd behavior with 'inject'. Try replacing these original lines of code (Lines 85-88):
Code:
retains = states.inject([]) { |r, state|
      next unless state.retain_on_death?
      r.push([state.id, @state_turns[state.id], @state_steps[state.id]])
    }
with this new fix:
Code:
retains = states.inject([]) { |r, state|
      if state.retain_on_death?
        r.push([state.id, @state_turns[state.id], @state_steps[state.id]])
      end
      r
    }
 

Jatopian

Veteran
Veteran
Joined
Jul 5, 2015
Messages
53
Reaction score
15
First Language
English
Primarily Uses
That appears to work perfectly. Thanks!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,018
Members
137,563
Latest member
MinyakaAeon
Top