Looking for a script that will let me change the order of party members.

I created a summoner type class that summons companions during and between battles. The only problem is when I add them to the party, they automatically go to the end of the list of followers. I need either a script call or some sort of common event that will put the pet in one of the top party slots, preferably slot 4.


I found this...


idx1 = 0
idx2 = $game_actors[2].index
$game_party.swap_order(idx1, idx2)


for VX and tried to edit it to get it to work with js, but had no luck. Any help would be greatly appreciated.
if it adds them to the end, something like this should work:


idx1 = 3
idx2 = $gameParty.members().length - 1;
$gameParty.swapOrder(idx1, idx2);


Of course you'd only want to do that if there are more than 4 members in the party after adding them.
Awesome! Seems to have fixed my issue. The community here has been great so far. Thanks!

Original thread: https://forums.rpgmakerweb.com/threads/looking-for-a-script-that-will-let-me-change-the-order-of-party-members.56993/