[VXA] Problem with Szyu's Items Class Restriction

Good morning, afternoon, evening everyone.

I seem to have a problem with this script

Szyu's Items Class Restriction




The script on it's own works just fine...

it's just that I made this small edit on window_actorcommand

13.12.2020_16.27.02_REC.png


I made it so that when an actor is inflicted with either of these two states will not have access to the item command in battle.

However. As soon as the actor was inflicted with the states I get this error

13.12.2020_16.30.37_REC.png


It should be noted that when I restored the Window_Actorcommand script back to it's default form, this script has caused me no problems...

Is there a way around this issue? I really would appreciate anyone's help here.
Instead of modifying the base code, just create a new instance on a blank space under materials. (Will save you from troubleshooting headaches in the future). That being said, the script had nothing to do with the error itself on my end. It was just a matter of fixing the syntax on the code. (You had a pair of () where you didn't need them.) It should work just fine now.
Ruby:
#==============================================================================
# ** Window_ActorCommand
#------------------------------------------------------------------------------
#  This window is for selecting an actor's action on the battle screen.
#==============================================================================

class Window_ActorCommand < Window_Command
  #--------------------------------------------------------------------------
  # * Add Item Command to List
  #--------------------------------------------------------------------------
  def add_item_command
    add_command(Vocab::item, :item, !(@actor.state?(27) or @actor.state?(41)))
  end
end
No, I'm sorry but I am still getting the exact same error despite having copy pasted what you posted here...
Then you've definitely changed something else outside of both of these scripts or there is another hidden conflict. Would you be okay with sharing your project file for a better inspection? (You can PM me if it helps).
Untested, but try this as a new snippet below Szyu's script:
Ruby:
class Window_BattleActor < Window_BattleStatus
  #--------------------------------------------------------------------------
  # * Get Activation State of Selection Item
  #--------------------------------------------------------------------------
  def current_item_enabled?
    return false unless BattleManager.actor.input.item
    return false if !BattleManager.actor.input.item.is_a?(RPG::UsableItem) ||
      BattleManager.actor.input.item.forbid_classes.include?(BattleManager.actor.input.subject.class_id) ||
      BattleManager.actor.input.item.forbid_actors.include?(BattleManager.actor.input.subject.id)
    return true
  end
end

Basically, it's just checking to see if the actor's current input item is valid.
@A-Moonless-Night
That won't work.
This check:
Code:
BattleManager.actor.input.item.is_a?(RPG::UsableItem)
Already takes care of nil cases, since nil is not a RPG::UsableItem.

According to the error message and the relevant line(s), the item itself is present, but the forbid_classes method/variable returns nil on it.
You didn't mention this, but the error can only happen when you use a skill on a party member. That's because the script only loads these new variables for items and not skills, therefore they are not defined for skills.

2 ways to fix this:
Spoiler: Way #1
You can make the script load these new variables for skills too.
Just change this line:
Code:
groups = [$data_items, $data_weapons, $data_armors]
To this:
Code:
groups = [$data_items, $data_skills, $data_weapons, $data_armors]
Spoiler: Way #2
Eliminate skills from the extra check for these variables.
Replace this line:
Code:
return false if !BattleManager.actor.input.item.is_a?(RPG::UsableItem) ||
With this one:
Code:
return false if !BattleManager.actor.input.item.is_a?(RPG::Item) ||

Original thread: https://forums.rpgmakerweb.com/threads/vxa-problem-with-szyus-items-class-restriction.130938/