Grab coordinates of nearest event in front of player

I want to continuously move an event on top of the nearest event within the player sprite's field of vision.
Example, I want to move Event1. The coordinates I want to move it to are variables that constantly change to the coordinates of whatever event is nearest to the player. How would I go about doing that?
Dunno if this is doable with the ingame mechanic only, you could do coordinates for each event and when the player is whitin that range then event 1 jumps in but thats alot of variable tbh, youd need for each event 2.
Thats the only way i imagine this would be possible, but i may be wrong.... otherwise a script / plugin could do the trick.

Or another solution would be to use zones and / or terrain tags...
Dunno if this is doable with the ingame mechanic only, you could do coordinates for each event and when the player is whitin that range then event 1 jumps in but thats alot of variable tbh, youd need for each event 2.
Thats the only way i imagine this would be possible, but i may be wrong.... otherwise a script / plugin could do the trick.
- Yeah I initially thought about doing just a whole bunch of variables, but that's way too messy and space-intensive to work for me. I just wanted two variables that get constantly changed.

- The only plugins I saw were ones that executed a specific event within a certain range, but none of them worked for what I wanted to do.
And to use zones / terrain?
You still would need to set them up on each map and event but you would not need a bunch of variables...
thought something like put zones / terrain 2,3 blocks around the event or wherever you like and a paralel event with a condition, if player on zone / terrain 1 then event 1 jump to event 2, if player on z / t 2 then event 1 jump to event 3 and so on...
The good thing with this is you can reuse zones and terrain for each map anew so no messy variable salad. You can even ad an player looking right, left, up, down conditional branch in the mix.

Ofc there is also always the option to ask people here if they would be willing to script something like this, you can request it here: https://forums.rpgmakerweb.com/index.php?forums/js-plugin-requests.136/
And to use zones / terrain?
You still would need to set them up on each map and event but you would not need a bunch of variables...
thought something like put zones / terrain 2,3 blocks around the event or wherever you like and a paralel event with a condition, if player on zone / terrain 1 then event 1 jump to event 2, if player on z / t 2 then event 1 jump to event 3 and so on...
The good thing with this is you can reuse zones and terrain for each map anew so no messy variable salad. You can even ad an player looking right, left, up, down conditional branch in the mix.

Ofc there is also always the option to ask people here if they would be willing to script something like this, you can request it here: https://forums.rpgmakerweb.com/index.php?forums/js-plugin-requests.136/
Hmm... I could still see the code for that getting a bit convoluted, but it's way better than the other option. I'll try and implement that and see how it works across maps and such. I'll put in a request if I need something a bit more streamlined. Thanks for the idea!
Yes, ofc it depends on how many events you want to use it per map, or rather if you use the region thing, then you wont need the other events since you can just jump the event you want wherever you want it.
I just made something like that in a few min, its pretty easy tbh.
I added it to my demo town, you can playtest it and alos look into the events.
You can find it here:
Yeah, I figured it out last night in a couple mins. Thanks again c:
The region solution works well enough for me. Only problem is if I wanted to put the event on top of a nearby moving event, since I can't set region ID's in a script as far as I know. But I can live without that in this scenario.
Yeah, I figured it out last night in a couple mins. Thanks again c:
The region solution works well enough for me. Only problem is if I wanted to put the event on top of a nearby moving event, since I can't set region ID's in a script as far as I know. But I can live without that in this scenario.


Look here, maybe that is what you need.
Look here, maybe that is what you need.
I meant, if "Event1" has a random movement route, I wouldn't be able to use regions to move "Event2" on top of it, since I can't place/remove region tiles from within a script. I can only check for the region IDs that are already there, but I'd need to have a "moving" set of region ID's that stay around "Event1". Kinda hard to explain, but for now it's not important xD
I meant, if "Event1" has a random movement route, I wouldn't be able to use regions to move "Event2" on top of it, since I can't place/remove region tiles from within a script. I can only check for the region IDs that are already there, but I'd need to have a "moving" set of region ID's that stay around "Event1". Kinda hard to explain, but for now it's not important xD
Ohh, ok. i thought you need the region id in a script call. 😀
You could still make those with variable x,y for event 1 and x,y for event 2 but depending on the events youd need alot... or just a mix of both, region here and there, xy here and there.
I dont know what you need it for exactly so its hard to guess. ^^

Original thread: https://forums.rpgmakerweb.com/threads/grab-coordinates-of-nearest-event-in-front-of-player.143401/