Script call for Movement > Set Event Location > Exchange with another event

Hello,

I'd like to exchange an event location with another event designated with a variable, rather than the drop down list provided in the editor. I looked through the script call spreadsheet, but it didn't have anything for that specifically. Anyone know what it is?

Thanks!

EDIT: By the way, I found this in rpg_objects.js, but have know idea how to implement it:

Code:
// Set Event Location
Game_Interpreter.prototype.command203 = function() {
    var character = this.character(this._params[0]);
    if (character) {
        if (this._params[1] === 0) {  // Direct designation
            character.locate(this._params[2], this._params[3]);
        } else if (this._params[1] === 1) {  // Designation with variables
            var x = $gameVariables.value(this._params[2]);
            var y = $gameVariables.value(this._params[3]);
            character.locate(x, y);
        } else {  // Exchange with another event
            var character2 = this.character(this._params[2]);
            if (character2) {
                character.swap(character2);
            }
        }
        if (this._params[4] > 0) {
            character.setDirection(this._params[4]);
        }
    }
    return true;
};
Hello,

I'd like to exchange an event location with another event designated with a variable
Code:
$gameMap.event(1).swap($gameMap.event(2));
This will exchange (aka. "swap") events 1 & 2.

Code:
$gameMap.event($gameVariables.value(1)).swap($gameMap.event($gameVariables.value(2)));
This will exchange (aka. "swap") events of what Game Variables 1 & 2 are set as.

Full Example:
Spoiler
Code:
$gameVariables.setValue(1, 5);
$gameVariables.setValue(2, 8);
$gameMap.event($gameVariables.value(1)).swap($gameMap.event($gameVariables.value(2)));
This will swap events 5 & 8, because Variable 1 is set to 5 & Variable 2 is set to 8.

Let me know how it goes. Hope all works how you need it to. 🙂
Happy Game Making! 🙂
@ct_bolt

Thank you! That was a very clear and thorough explanation and I greatly appreciate it. It works perfectly.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/script-call-for-movement-set-event-location-exchange-with-another-event.115397/