How do I sort through all the events on the map?

Events on the map are created during the game.
We don't know how many of them there are.
Please explain how to set up a distance check from the player to each one? (in one event!!!)
Do you literally mean an event that runs a distance check on every single event at once? Though I can't say for certain, I'd imagine that event could introduce considerable load.

Or, are you simply looking for a way to check the distance from specific events, as the need arises during your game? There's bound to be a way to do this, since the engine knows the coordinates of everything. I saw a mention of:

this.ActorDistance(var, actor, actor);

...in a mostly unrelated post (see the @NatePlays reply on 9/24) .

I'm wondering if the trailing 'actor' in that statement could be an event number instead. Or, maybe there's an better way...

Edit: Sorry, above is for MV, I'm uncertain if it pertains directly to MZ.
Do you literally mean an event that runs a distance check on every single event at once? Though I can't say for certain, I'd imagine that event could introduce considerable load.

Or, are you simply looking for a way to check the distance from specific events, as the need arises during your game? There's bound to be a way to do this, since the engine knows the coordinates of everything. I saw a mention of:

this.ActorDistance(var, actor, actor);

...in a mostly unrelated post (see the @NatePlays reply on 9/24) .

I'm wondering if the trailing 'actor' in that statement could be an event number instead. Or, maybe there's an better way...

Edit: Sorry, above is for MV, I'm uncertain if it pertains directly to MZ.
Wait wait wait wait... That function is exclusive to the SRPG Battle plugin, as with that you can set your actors in different spots on the map instead of right behind you. Yeah, it has an Event version, but it is still not relevant for MV.
@tvorimvsevmeste you might want to see this:

JavaScript:
$gameVariables.setValue(w, $gameMap.distance($gamePlayer.x, $gamePlayer.y, $gameMap.event(z).x, $gameMap.event(z).y) )

This sets variable W to the distance between the player (party leader) and an event Z. I don't know if it works in MZ but the versions are similar enough the functions should still be the same.

Then make a loop or a sequence that tests for every event number you need (say, 1 to 10) and save them to variables (say, 101 to 120).

The easy way is to just copy-paste the script above and change W and Z accordingly.
And how can I make it for EVERY event on map if I don`t know how much 😮 events shall respawn on that map in advance?
Please help me! :LZSsmile:
Not to be a bother, but have you tried looking on Google as "RMMV script get all events" or even on this forum?

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-sort-through-all-the-events-on-the-map.129087/