Script Call to Equip Weapons

Status
Not open for further replies.

Faherya

The Knight of the Sad Figure
Veteran
Joined
Jul 25, 2013
Messages
237
Reaction score
534
First Language
Portuguese
Primarily Uses
RMVXA
Hello guys, how are you?
Well, I am having a problem with the following call. I need this command to immediately equip a character with a weapon:
Code:
$gameActors.actor(1).changeEquip(1, $dataWeapons[1]);
The program documentation doesn't help, so I'm guessing that the argument specifications listed here are correct (slotID, equipmentID). However, the command does not work or return any errors. It is simply ignored. Any idea what the error might be? For registration, I already checked and the character can be equipped with the specified weapon type. It is for a challenge from a local forum, so I cannot insert any external plugins, even if to facilitate the configuration.
 

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
840
Reaction score
338
First Language
Javascript
Primarily Uses
RMMV
I need this command to immediately equip a character with a weapon
At work now on my phone so can't help much but I'll try to look it up on my phone...
I think maybe like...
Code:
$gameActors.actor(1).changeEquip(0, $dataWeapons[1])
(0 = weapon, 1 = shield, 2 = headgear, 3 = chest armor, 4 = accessory)
Use 0 & $dataWeapons[n] for weapons
Use 1 through 4 & $dataArmors[n] for armor.

Well let me know if that works for ya.
(Ps. I changed it since my first post)
@Faherya
Pretty sure but... can't really try it yet.
 
Last edited:

Faherya

The Knight of the Sad Figure
Veteran
Joined
Jul 25, 2013
Messages
237
Reaction score
534
First Language
Portuguese
Primarily Uses
RMVXA
Thanks for the answer. I tried to switch between the object and the ID, in addition to trying all possible slots. The result was the same. I was here looking at the method in question, but I don't know much about Js to understand. :kaoswt:
Code:
Game_Actor.prototype.changeEquip = function(slotId, item) {
    if (this.tradeItemWithParty(item, this.equips()[slotId]) &&
            (!item || this.equipSlots()[slotId] === item.etypeId)) {
        this._equips[slotId].setObject(item);
        this.refresh();
    }
};
Edit: Thanks again, I was also testing gameActors haha. But now I got an error (with or without the "_" in front of an actor):

JavaScript:
TypeError: Cannot read property '1' of undefined
    at eval (eval at Game_Interpreter.command355 (rpg_objects.js:10500), <anonymous>:1:19)
    at Game_Interpreter.command355 (rpg_objects.js:10500)
    at Game_Interpreter.executeCommand (rpg_objects.js:8930)
    at Game_Interpreter.update (rpg_objects.js:8838)
    at Game_Map.updateInterpreter (rpg_objects.js:6115)
    at Game_Map.update (rpg_objects.js:6022)
    at Scene_Map.updateMain (rpg_scenes.js:608)
    at Scene_Map.updateMainMultiply (rpg_scenes.js:600)
    at Scene_Map.update (rpg_scenes.js:589)
    at Function.SceneManager.updateScene (rpg_managers.js:2024)
 
Last edited:

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
840
Reaction score
338
First Language
Javascript
Primarily Uses
RMMV
Did you try this?
Code:
$gameActors.actor(1).changeEquip(0, $dataWeapons[1])
(0 = weapon, 1 = shield, 2 = headgear, 3 = chest armor, 4 = accessory)
Use 0 & $dataWeapons[n] for weapons
Use 1 through 4 & $dataArmors[n] for armor.

Pretty sure that's it but can't really try it yet.

(Sooo pretty sure you were very close just needed to change the 1 to a 0 lol)
 

Faherya

The Knight of the Sad Figure
Veteran
Joined
Jul 25, 2013
Messages
237
Reaction score
534
First Language
Portuguese
Primarily Uses
RMVXA
Yes, I tried, I'm following your edits. :D
However, it was the same. It does not change the equipment, it does not generate an error. I don't have any extra code installed, so there can't be any interference.
 

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
840
Reaction score
338
First Language
Javascript
Primarily Uses
RMMV
Yes, I tried, I'm following your edits. :D
However, it was the same. It does not change the equipment, it does not generate an error. I don't have any extra code installed, so there can't be any interference.
Hmmmm odd using the 0 instead of 1 should have worked.
just so I'm sure you're trying to change actor I'd #1's weapon right? Not party member #1?
Pretty sure but... can't really try it yet.

Edit:
maybe try this using Id instead?
 
Last edited:

Faherya

The Knight of the Sad Figure
Veteran
Joined
Jul 25, 2013
Messages
237
Reaction score
534
First Language
Portuguese
Primarily Uses
RMVXA
[...]
just so I'm sure you're trying to change actor I'd #1's weapon right? Not party member #1?
[...]
Yes, but now that you mention it, it makes no difference. It is a micro project, there is only one character and there are never changes in the group. I'll try with gameParty. o/
 

rainyday

Veteran
Veteran
Joined
Nov 5, 2019
Messages
57
Reaction score
27
First Language
English
Primarily Uses
RMMV
Do you have the weapon you want to equip onto the actor in your inventory? changeEquip needs an unused copy of that weapon or armor in your inventory to work. If you don't want this for whatever reason, use forceChangeEquip instead(it takes the same parameters as input).
 

Faherya

The Knight of the Sad Figure
Veteran
Joined
Jul 25, 2013
Messages
237
Reaction score
534
First Language
Portuguese
Primarily Uses
RMVXA
Ah, that worked perfectly. Many thanks to both! :kaoluv:
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
6,748
Reaction score
4,592
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

I count on someone one time, I let them promise something to me, and one week later it's complete silence as I'm completely let down. I hate everything.
Everytime I need to write dialogues I find myself writing new music pieces... what kind of trick is this?!
Me Being Dumb spending hrs trying to figure out Irenas Visual Novel busts plugin..lol. I'm probably missing something stupid and obvious xDD

let the journey begin >w>
X.X ok... I guess I'll just have to think about 48x48 a little differently. Its not "room for more work"..."its room for more detail!...yay"
Alexa, play Buck-Tick - Dress

Forum statistics

Threads
99,218
Messages
963,151
Members
130,805
Latest member
kraufen
Top