Equip a weapon/armor using JS

Lady_JJ

Veteran
Veteran
Joined
May 6, 2019
Messages
46
Reaction score
22
First Language
English
Primarily Uses
RMMV
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.
 
Last edited:

SeaPhoenix

Veteran
Veteran
Joined
May 14, 2015
Messages
222
Reaction score
191
First Language
English
Primarily Uses
RMMV
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.
 

Lady_JJ

Veteran
Veteran
Joined
May 6, 2019
Messages
46
Reaction score
22
First Language
English
Primarily Uses
RMMV
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.
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,418
Reaction score
669
First Language
Portuguese - Br
Primarily Uses
RMMV
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..
 

Lady_JJ

Veteran
Veteran
Joined
May 6, 2019
Messages
46
Reaction score
22
First Language
English
Primarily Uses
RMMV
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....
 

SeaPhoenix

Veteran
Veteran
Joined
May 14, 2015
Messages
222
Reaction score
191
First Language
English
Primarily Uses
RMMV
Glad that worked, @Lady_JJ! Thanks for letting me know too that you bought the game... I hope you enjoy it! :smile:
 

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

Latest Threads

Latest Profile Posts

Would Jump into Javascript be best off continuing to break down the MV core files, or would people prefer a quick detour to cover everything that's changed in the core from MV to MZ?
Not going to lie... PIXI Particles make fantastic graphics... But predicting the hitbox of something with a "fixed size" but whose graphics can stick out past that, is quite challenging. :kaoswt:
Would you like a glass of spiders?
Besides my Might and Magic inspired project, I have always wanted to make a Fire Emblem-like game. Time is the culprit... Between life, composing music packs, and working on a game can it be done!? The tactical plugins for MV work quite well based on what I have tested.

Forum statistics

Threads
100,530
Messages
976,885
Members
132,081
Latest member
Kaezyelnatz
Top