Equipping weapon with script

I know this is not the usual way to equip a weapon, the reason I am using this method is down to the user being able to select a Class for the character before the game begins. The weapon to be equipped cannot be used by each class.
Code:
  ◆Script:$gameActors.actor(1).changeEquip(1, $dataWeapons[22]);
This is the script which according to the MV Script call list should work. The weapon is just removed entirely however, I also cannot find it in the inventory or item book, despite this coming after
Code:
  ◆Change Weapons:Spear + 1
The spear is weapon 22 in the database, equip 1 is for weapons.
changeEquip's first argument is slotId, not the equip type ID; slotId starts counting from 0, so try replacing the 1 with a zero. 🙂

That said, this all seems possible with eventing. Conditional Branch > Actor > Class to check the actor's class, then Change Equipment in each of the branches as appropriate.
changeEquip's first argument is slotId, not the equip type ID; slotId starts counting from 0, so try replacing the 1 with a zero.
You were right, thanks. Changing slotID to 0 fixed it.
That said, this all seems possible with eventing. Conditional Branch > Actor > Class to check the actor's class, then Change Equipment in each of the branches as appropriate.
I have that check before the weapon is given to the player. It still does not let me select the spear from the dropdown menu.
I have that check before the weapon is given to the player. It still does not let me select the spear from the dropdown menu.
Oh, yes, I'd forgotten about that quirk in the editor. 😔

Happy RPG Making! ^_^

Original thread: https://forums.rpgmakerweb.com/threads/equipping-weapon-with-script.105600/