Script Call to Equip Weapons

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.
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.

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. 😅
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)
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)
Yes, I tried, I'm following your edits. 😀
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.
Yes, I tried, I'm following your edits. 😀
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?
[...]
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/
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).
Ah, that worked perfectly. Many thanks to both! 😍

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.

Original thread: https://forums.rpgmakerweb.com/threads/script-call-to-equip-weapons.118023/