Set Event Location Opposite?

Is there a way to tell the system "Whatever is in this location needs to be teleported somewhere else." Basically, the oposite of Set Event Location, where the specific event doesn't matter, only it's location?
Have a parallel event with, say, a 6 frame wait.

Use Get Location Info -> Info Type Event ID

Conditional Branch -> the variable with that ID is > 0
- use the script call for Set Event Location:
$gameMap.event($gameVariables.value(42)).setPosition(x, y)
where 42 is the ID of the variable you've been using, and x and y are the tile coordinates to move it to.
You can get the Event ID using this:

1734543881956.png


Unfortunately, "Set Event Location" doesn't accept a Variable, but we can do this:

Code:
const eventId = $gameVariables.value(1); // <-- Variable ID from "Get Location Info"
const event = $gameMap.event(eventId);

if (event) {
  event.locate(
    $gameVariables.value(2), // <-- Variable ID that holds target X
    $gameVariables.value(3), // <-- Variable ID that holds target Y
  );
}
Luckily, this script simply does nothing when there's no event on this spot.
I'm... not sure I understand what either of you are talking about. Could you maybe dumb it down a little?
I'm... not sure I understand what either of you are talking about. Could you maybe dumb it down a little?
We're willing to help, but that's not a very useful reply. We both told you which specific event commands to use, and @Aerosys even provided a screenshot.

You just saying "I don't understand" doesn't give us anything to work with.

Which words do you not understand? Which instruction can you not follow? Show a screenshot of the work you've done so far.
Have a parallel event with, say, a 6 frame wait.

Use Get Location Info -> Info Type Event ID

Conditional Branch -> the variable with that ID is > 0
- use the script call for Set Event Location:
$gameMap.event($gameVariables.value(42)).setPosition(x, y)
where 42 is the ID of the variable you've been using, and x and y are the tile coordinates to move it to.
Do you have to use a Parallel Event? Or is that only if you're not sure when an Event is going to be in that location? Is the Conditional Branch part of that?
I think the code means you put the variable you saved the ID to in the "42" possition, and you put the coördenates of where you want the Event to go in the (x, y). Is that correct?

You can get the Event ID using this:

View attachment 326149

Unfortunately, "Set Event Location" doesn't accept a Variable, but we can do this:

Code:
const eventId = $gameVariables.value(1); // <-- Variable ID from "Get Location Info"
const event = $gameMap.event(eventId);

if (event) {
  event.locate(
    $gameVariables.value(2), // <-- Variable ID that holds target X
    $gameVariables.value(3), // <-- Variable ID that holds target Y
  );
}
Luckily, this script simply does nothing when there's no event on this spot.

To me, it seems like this code does the same thing as what the "Get Location Info" above it does. Clearly it doesn't, as you wouldn't have recommended it otherwise, but I don't know what it does. Where do I put the location I want to transfer the event to?
Do you have to use a Parallel Event? Or is that only if you're not sure when an Event is going to be in that location?
Correct - you didn't really explain how you're using this, so I assumed that if you don't know which event is going to be there, you also don't know when it's going to be there.

If you want to just do this at a specific time, then you just do it in a regular event, not parallel.

Is the Conditional Branch part of that?
The conditional branch is checking for the variable to have an event ID that's not 0 - checking that there is an event on that space.

I think the code means you put the variable you saved the ID to in the "42" possition, and you put the coördenates of where you want the Event to go in the (x, y). Is that correct?
Yes, that's what I said:
where 42 is the ID of the variable you've been using, and x and y are the tile coordinates to move it to.


To me, it seems like this code does the same thing as what the "Get Location Info" above it does.
No, the very first line of that code is telling you where to put the ID of the variable you already used Get Location Info with.

Where do I put the location I want to transfer the event to?
Where he shows you.
1734553870004.png


If you don't need to use variables for that, you simply type the numbers the same way I showed you in my post.

The two answers are basically the same, Aerosys' just has a few more lines.
Okay, thanks! That might be what I need. I probably won't be able to try it right now (I am very tired), but when I get to it, I'll use that.
Is there a way to tell the system "Whatever is in this location needs to be teleported somewhere else." Basically, the oposite of Set Event Location, where the specific event doesn't matter, only it's location.
Assuming I understood this correctly, here is another possibility if you are comfortable with a script call:

Spoiler
In a parallel event, use this script call and a wait command of at least a few frames - use coordinate numbers for x1, y1 and x2, y2:

JavaScript:
$gameMap.eventsXy(x1, y1)[0]?.locate(x2, y2);

Quick info:
"$gameMap" : the game map constructor.

"eventsXy(x1, y1)[0]" : look for events at x1, y1 and give me the first event in this array/list.

"?." : if there is nothing, return undefined instead of an error, otherwise ->

"locate(x2, y2)" : locate the event to x2, y2

Example:
JavaScript:
$gameMap.eventsXy(2, 4)[0]?.locate(5, 7);
If there is an event at (2, 4), locate it to (5, 7).
Assuming I understood this correctly, here is another possibility if you are comfortable with a script call:

Spoiler
In a parallel event, use this script call and a wait command of at least a few frames - use coordinate numbers for x1, y1 and x2, y2:

JavaScript:
$gameMap.eventsXy(x1, y1)[0]?.locate(x2, y2);

Quick info:
"$gameMap" : the game map constructor.

"eventsXy(x1, y1)[0]" : look for events at x1, y1 and give me the first event in this array/list.

"?." : if there is nothing, return undefined instead of an error, otherwise ->

"locate(x2, y2)" : locate the event to x2, y2

Example:
JavaScript:
$gameMap.eventsXy(2, 4)[0]?.locate(5, 7);
If there is an event at (2, 4), locate it to (5, 7).
That's much simpler. I'll try that first.

Original thread: https://forums.rpgmakerweb.com/threads/set-event-location-opposite.174001/