Check if event on position.

I still curently developping the core of my game and still enconter many trouble.


Curently I want to check if an event exist in a (x-y) position other then then player himself.


I curently found a kind of code that can work but pretty eavy, so I hope you give me a better solution. 


Thansk for your great help.
At least directly within the maker,  I don't think their is.  You probably won't get a cleaner method other than using a script.  I can think of a few work arounds,  but that's going to not be as fun as I'm making it out to be.  That and I'd have to see your project haha.


TL😀R -  I think you should use a script.
Yes, there is a way.  Do you just want to know if there IS an event at the player's position, or do you want the event ID?


$gameMap.eventIdXy($gamePlayer.x, $gamePlayer.y) will give you the id of the event at the player's position, or 0 if there isn't one.
UNfortunatly it's not at the player position that I lookinf for but at a specific position. But your code seem to work, I just need to replace  ($gamePlayer.x, $gamePlayer.y)  by what I want to look for. But I think that I can use your code a lot and that will sovle my trouble, I will test, better then my code:

Code:
var i, a, b, c, d, e, n, mapId, eventId
mapId = $gameMap.mapId(); eventId = this._eventId; e = $gameMap._events; 
i = 1; n = 0; a = this.character(0).event().x; b = this.character(0).event().y; 
while (i < e.length) {if (e[i] && i !==eventId){c = e[i]._x ; d = e[i]._y;
if (a === c && b === d && e[i]._priorityType !== 0){n=1;}}i++}
if (n===0){this.character(0).locate(a, b;}
you can use event commands to check any position of the current map for a lot more info.


Use control variable to store X and Y of whatever position you want into two variables, then use get location info with those two variables as coordinates and a third variable to store the result - and that result may be an event ID, the region ID, or a few other things.
I know that but using variable cause too much instability when a lot if event can use same variable. I love avoid these kind of programming that resulte in many falure in my past codes. Now I only need to fond how to get variable value in a script, Im sure I will found how in few time.
$gameVariables.value(variable_id)
thanks, my code working a lot faster with your help now.

Original thread: https://forums.rpgmakerweb.com/threads/check-if-event-on-position.64085/