Swapping Actors via a script (notetags included)

So, I am working on a script that swaps a character with another using a command or a skill. I have set the notetag, but I have no idea on how to do that. I mean, I know what I want to do, but I cannot translate that procedure to Ruby.

Here's the procedure (or Algorithm if you prefer):

1. Read notetag.

2. Call the Actor database

3. Look for Actor x from the notetag

4. Remove Actor y from party

5. Add Actor x to the party

Here's a portion of the script:

Code:
  alias ActorSelect, ActorSwap# Notetag for Skills      class RPG::Skill      def ActorSelect        if @note =~ /<SwapWith (.*)>/i          return $1.to_i        else          return 0        end  class RPG::Actor# Actor Swap        def ActorSwap                   #<- This is what I'm missing.      end  end
These functions behave exactly like the event command "change party member". You can use them to change the party :

class Game_Interpreter  def change_party_member(actorId, add, initialize_actor)    add_or_remove = 1    levelOne = 0     if add      add_or_remove = 0    end     if initialize_actor      levelOne = 1    end     @params = [actorId, add_or_remove, levelOne]    command_129  end   def add_party_member(actorId)    @params = [actorId, 0, 0]    command_129  end   def remove_party_member(actorId)    @params = [actorId, 1, 0]    command_129  endendJust call them like this:

Code:
$game_map.interpreter.remove_party_member(2)$game_map.interpreter.add_party_member(3)
Remember that those commands add the new actors to end of your party.
Whoops! I said add actor x, remove actor y instead of replace actor x with actor y. Wrote the wrong algorithm! Sorry for that.

Also, how do I set intergers on the character swap? I need Actor y's ID so it won't remove the wrong character.

And it seems to me that I am missing something, because it doesn't work for some reason. Do I need to call something?
You should explain what notetag you're talking about, where and how you read it - depending on that there might be a big flaw on your process.


If an actor has notetags in the notebox that are for several scripts, then it depends on the scripts when this data is processed. Some scripts load that data when they are called, but others read that data only during newgame and then store it internally.


If an added script has its own data about the actors, then changing the actors might not change the script's internal data. And then the script might react to the new actor with the notetags from the old actor.


So you better tell us more details about what you want to achieve, so that we can check if that has side effects or not.
Okay, let's start over then.

The script that I'm working on is essentially replacing a character (Iet's call him Actor X) with another character (called Actor Y) using either a Battle Command or a Skill (whichever works). If it is a skill, a notetag will trigger the script (let's say the notetag is <swap ok>) which in turn, reads Actor X's notetag (say, <SwapWith Y>) that corresponds to the Actor Y's ID. A similar applies if it is a battle command.

Note the following:

-The script needs to be plug and play (copy-paste script, add notetags, done).

-To clarify, Actor X and  Actor Y are separate characters, not sprite swaps.

-It needs to be used both on map and in battle.

-If possible, all states from Actor X are transfered to Actor Y after swapping.

-If also possible, allow player to heal and equip the Actor Y like normal, but he is not part of the party (kinda like a ghost, if anybody watched the YuGiOh anime knows what I'm trying to say)

I created the notetags by following this tutorial:

http://forums.rpgmakerweb.com/index.php?/topic/1686-a-guide-to-notetagging/

Hopefully this makes it more clear.

Original thread: https://forums.rpgmakerweb.com/threads/swapping-actors-via-a-script-notetags-included.36784/