Equip a weapon/armor using JS

I've been searching for days and have found many threads dealing with looking to see if a particular was equipped, or if a particular weapon is equipped then do this else do that, but there is only one thread I can find that deals with the simple equip this weapon.

This method coincides exactly with the RMMV Script Calls - Google Sheet (see row 55).

But I can't get it to work. My experience with JS is so-o-o-o- newbie... Here is what I have


1589723337974.png


Do I not have it properly written in 'Script' or should I have it written elsewhere / in another fashion? Thank you.
In your script call $gameActors.actor(1).changeEquip(0, 5) it should be $gameActors.actor(1).changeEquip(0, $dataWeapons[5]) instead.

Or since you're using variable 3 to store of the value of the weapon id, you can also use $gameActors.actor(1).changeEquip(0, $dataWeapons[$gameVariables.value(3)]) if you want to refer to the weapon id by variable number instead.
Oh my word! I thought I had tried the $dataWeapons[5] and since that didn't work (maybe a typo on my end?), I chose to forego the variable and go straight to the literal. I am grateful to you for sending me back to $dataWeapons[5], and even moreso for showing me how to use a stored variable to re-equip. It's exactly what I needed. Thank you so much.

@SeaPhoenix As an aside, I just bought/downloaded The Lost Art of Innkeeping last night and I'm really looking forward to playing it.
Ops! Sorry, someone already answers that ^^''
----
Hi there!
Yeah, these script calls are not so intuitive to use. I'm already making a plugin that simplifies that.

But the correct script call for you to use is that one:
$gameActors.actor(1).changeEquip(0, $dataWeapons[1])

you have to use $dataWeapons[ID] or $dataArmors[ID] etc..
Thanks to you, Eliaquim, as well. I did go back to the Google doc sheet and saw that I had completely missed the instruction to use $dataWeapons(x) and not just x as item. One more tiny step in the learning curve for me....
Glad that worked, @Lady_JJ! Thanks for letting me know too that you bought the game... I hope you enjoy it! 🙂

Original thread: https://forums.rpgmakerweb.com/threads/equip-a-weapon-armor-using-js.121681/