[Ace] Undefined method: "item" for nil:nilclass?

qa7xFqG.png


alias cp_bv2_use_item use_item def use_item ## Process an actor set switch. item = @subject.current_action.item <----- The relevant line if !item.swap_party.nil? && item.swap_party > 0 user_swap_party else cp_bv2_use_item end endRight at the end of battle, just after EXP/items obtained are stated.This only appears when the skill "Ultimate Burst" is used, and ends the battle with sufficient damage.

I can't see any database issues. This hasn't happened before, and I don't think I changed anything special.

What does this error mean?
In 99% of all cases it means that you loaded an old savegame after adding a new script.


Technically it means that some data wasn't initialized, and in 99% of all cases the scripts initialize their data on the "new game" command, so if you added a script and then loaded an old savefile from before that script was added, then the "undefined for NIL" error messages pop up when the data from the script is needed.
it means that the variable @subject.current_action does not have a legitimate object associated with the current_action method. which is causing the item method to be called on a nil object, which does not have an item method.

Try this?

Code:
 alias cp_bv2_use_item use_item  def use_item  ## Process an actor set switch.    return unless @subject && @subject.current_action    return unless item = @subject.current_action.item    if !item.swap_party.nil? && item.swap_party > 0      user_swap_party    else      cp_bv2_use_item    end  end
In 99% of all cases it means that you loaded an old savegame after adding a new script.

Technically it means that some data wasn't initialized, and in 99% of all cases the scripts initialize their data on the "new game" command, so if you added a script and then loaded an old savefile from before that script was added, then the "undefined for NIL" error messages pop up when the data from the script is needed.
I've noticed a lot of scripts doing this and I really wonder why they don't do the proper checks  on the "load game" command too. It'd be just a couple of extra lines and would make everyone's life easier.
All fixed, muchas gracias Dekita 🙂
No worries dude, it really wasnt any hassle at all 😀

Original thread: https://forums.rpgmakerweb.com/threads/ace-undefined-method-item-for-nil-nilclass.38215/