Force Actor position in party

Usually when an actor joins the party, they go at the end of the line e.g. position 4.

However, if I want them to go somewhere else in the line e.g. position 2, I have to go through all the bother of taking the other actors out and then adding them back in.

Is there a script call which can force an actor into a particular follower position?

Thanks.
Yes, you can use something like the following :

Code:
# @actors cannot be accessed normally; use work-around to gain access
party = $game_party.instance_variable_get(:@actors)
# insert(intPosition, dataToInsert)
# The following will place actor #4 to the first position in the party (leader)
party.insert(0, 4)
# Refresh $game_player and $game_map
$game_player.refresh
$game_map.need_refresh = true


# If you want to remove an existing party member, you can include the following with the above
# delete_at(intPosition)
# The following will delete the second actor in the party list
party.delete_at(1)
@Ossra I may not have used this correctly, but putting it into the event gave me this error message

upload_2017-10-5_20-30-33.png
Oh, I think the comments I put in are mucking with everything. Remove those before pasting the scriplet into the Script area in the event.
@Ossra I think that must have been it, because everything is fine now.

Thank you very much for your help.
Sorry for late reply, but you can also do it with a single script call, using the formation system's ability to swap actors around.

If you want to ensure the new actor goes into position 4, add them to the party with the Change Party Members command. Then ensure there are MORE than 4 members in the party (otherwise you'll get an error trying to swap them into position 4 if nobody else is already there, or you'll just be swapping them with themselves, which is a waste of time). I think you'd need to do Control Variables for that. Then just do a script call to swap the last member added with the position you want them in:

Code:
Change Party Members (add) Bill
Control Variables [015 Party Size] = Game Data > Other > Party Size
Conditional Branch: Variable [015 Party Size] > 4
  Script: $game_party.swap_order($game_party.members.size - 1, 3)
End

size - 1 is to get the last actor you added.
3 is the 4th position (starting counting at 0)

This does an automatic refresh so you don't need to add that step.

Mmm ... that would actually do a swap, so the person previously in that position would be moved to the end. It's not just an insert, shuffling everyone along one slot, so may not have the result you're after.
@Shaz That is probably a better solution and less prone to explode, really. I have been away from RPGVXA for so long I have forgotten a lot of the default functions.
Only if you actually want to do a swap - move someone else from that position to the end of the lineup. If you just want to shuffle, my method won't be suitable, and you'll need to delete/insert.
@Shaz That's really interesting. I can think of a use for that one for something else. Thanks.

Original thread: https://forums.rpgmakerweb.com/threads/force-actor-position-in-party.85261/