Transfer Equipment from Actor to Another

Tried to follow the instructions from this old thread but couldn't get it to work.


Hoping for some support. What am I doing wrong? Thanks in advance!
*I'm assuming actor(7) and actor(16) refer to Actor 0007 and Actor 0016 from the Database.
I am not sure why the script isn't working, someone else may be able to answer that. Alternatively, you can try the code found in this reddit thread if you want:
Spoiler
JavaScript:
for(var i = 0; i < 5; i++) {
if($gameActors.actor(1).equips()[i] != null) {
var x = $gameActors.actor(1).equips()[i].id;} else {
continue;}
if(i == 0 && x) {
$gameActors.actor(1).changeEquip(i, 0);
$gameActors.actor(2).changeEquip(i, $dataWeapons[x]);
} else if (i > 0 && x) {
$gameActors.actor(1).changeEquip(i, 0);
$gameActors.actor(2).changeEquip(i, $dataArmors[x]);
}}

You can also do this with just the eventing options if you want as well. Just set it to change equipment and select the options for each equipment type, setting them to none. this will push all the items to the player inventory they will just have to re-equip them after the character switch.
I don't have MV in front of me now so I can't check, but if _equips is an array, you would have to do
$gameActor(1)._equips = $gameActor(2)._equips.clone() and consider that I might have some syntax errors in there.

However, I wonder if just assigning like that will lose the items that the first actor already had equipped. The Change Equipment command would first unequip the old item then equip the new item. If you just clone the whole array, I'm not sure it would put the old equipment back into inventory.
Are you using any plugins that might change item behavior? I ask cause if you use any independent item plugins, the clone solution will likely cause other issues.
Pretty much all of this stuff is over my head, so I can't really troubleshoot--only blindly try suggestions.
If the code itself looks right, then maybe it IS another of the issues mentioned above.
Thanks for the help.

If I can't get it working, then I guess I'll just manually unequip the characters and then throw up a text message reminding the player to re-equip everything 😅
but couldn't get it to work.
what do you want it to do? And how do you check success?
Because with the event you screenshotted, you can't check for the success at all because I'm assuming you remove the actor that should get the change, assuming Theodross is actor 7?

(by the way, the leading zeroes on all IDs in the database are always unused, they are only there due to display formats. There is no actor 0016 in the engine, only actor 16)
Sorry, I guess it's ambiguous.
In my game, "Theodros" (Actor 7) grows up, which is represented by "Theodros" (Actor 16).

So the event is supposed to add Actor 16 to the party, transfer Actor 7 equipment to Actor 16, and then remove Actor 7.
When I test it, Actor 16 still has no equipment at the end. (He should have the sword and armor Actor 7 had)
how did you give actor 7 the equipment before the event?

And I strongly suggest to at least temporarily give all actors different names. You can rename them before deployment or before distributing any demos, but while you're developing the game the names should be different (for example "Theodros (young)" and "Theodros (adult)", just to prevent yourself from mistaken the commands because they look identical in the editor.

EDIT:
Error found. you're giving the actor 7 (first actor) the equipment worn by actor 16 (second actor) with your script command. Assignment commands (=) always means the first variable gets the data from the second.

but your description above said that you want to give actor 16 the equipment from actor 7, that means you'll have to switch the numbers in the script command
For my test, Actor(7) has starting equipment--a sword and body armour.--and Actor(16) has nothing.
I tried 7 and 16 both ways in the script, but neither work :rsad:
I kept both Actor(7) and Actor(16) in the party for the test. After the script, Actor(7) still has his sword and armour, and Actor(16) still has nothing.
In my game, "Theodros" (Actor 7) grows up, which is represented by "Theodros" (Actor 16).

Ah-huh ... you don't need to have a different actor for a "grown up" version of an existing actor. Just use Change Actor Graphics to change the sprite, face and battler to the grown-up version. You can also use Change Actor Class if that's something that's also meant to happen as part of growing up.

If you had stated in the first place what it was that you were trying to achieve, all this experimenting and failing wouldn't have been necessary, and you'd have had your answer much more quickly 🙂
Well, if the code had worked, it would've been easier, since the equipment is the only constant I wanted.

If I'm stuck, I guess I could do it with changing graphics, but would then need to manually adjust the old skills to the new ones I have set under the Grown Up Actor...
... Or, I guess you're saying that I could move all those Grow-Up-Actor-Skills and Traits into a Class instead?... That might work.

Thanks for the suggestion. I'll resort to it if this can't be solved with a quick Script.

Original thread: https://forums.rpgmakerweb.com/threads/transfer-equipment-from-actor-to-another.120457/