Yanfly Party System Swap Fix - Use Actor ID instead of Index number

I am using the YEA Party System, and I came across the Yanfly Party System Swap Fix by Soulpour777.

It uses two index numbers as arguments, then swaps the actors in those index locations.

I would like a slight alteration to this, where instead of 2 index locations, I would like to give it an Actor ID and an Index number to swap.

I.e. I want Actor4 to be put in spot 2.

If there is someone who can come up with this, that would be great!

Here is the script:

Spoiler
Code:
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# SYF [Soulpour Yanfly Fix] - Party System Swap Fix# Author: Soulpour777# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# $game_party.swap_order(n,n)class Game_Party < Game_Unit  #--------------------------------------------------------------------------  # Alias Listings  #--------------------------------------------------------------------------    alias :syf_yanfly_party_swap :swap_order   #--------------------------------------------------------------------------  # Swap Order  #--------------------------------------------------------------------------    def swap_order(index1, index2)    id1, id2 = @actors[index1], @actors[index2]    pos1 = @battle_members_array.index(id1)    pos2 = @battle_members_array.index(id2)    @battle_members_array[pos1] = id2 if pos1    @battle_members_array[pos2] = id1 if pos2    syf_yanfly_party_swap(index1, index2)  endend
Change

id1, id2 = @actors[index1], @actors[index2]to

Code:
id1, id2 = index1, @actors[index2]
Hm. I mean it works, the first time (kindof), but I tried executing the script call again, and a third time, and it kept changing it, but swapping different actors...
Code:
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# SYF [Soulpour Yanfly Fix] - Party System Swap Fix
# Author: Soulpour777
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Swap Order Fix – If you want to use the script call $game_party.swap_order(n,n)
class Game_Party < Game_Unit
  #--------------------------------------------------------------------------
  # Alias Listings
  #-------------------------------------------------------------------------- 
  alias :syf_yanfly_party_swap :swap_order
 
  #--------------------------------------------------------------------------
  # Swap Order
  #-------------------------------------------------------------------------- 
  def swap_order(index1, index2)
    id1, id2 = @actors[index1], @actors[index2]
    pos1 = @battle_members_array.index(id1)
    pos2 = @battle_members_array.index(id2)
    @battle_members_array[pos1] = id2 if pos1
    @battle_members_array[pos2] = id1 if pos2
    syf_yanfly_party_swap(index1, index2)
  end
 
end

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-party-system-swap-fix-use-actor-id-instead-of-index-number.35707/