Event Touching Event Conditional

I've been trying to figure out how to get this work, sadly Im no good at scripting yet, so I've been struggling understanding previous answers that could be applicable. I have a moving event that I want to be able to be caught by another event touching it, but I'm not sure how to set that up. I'm assuming it would need to be a script, but I'd be happy to be proven wrong! Any ideas?

EDIT: I'm dumb, seem to find my own solutions minutes after asking for help lately. Used a version of something someone else did in the forums, in case anyone is curious.


Math.abs($gameMap.event(14).x - $gameMap.event(16).x) + Math.abs($gameMap.event(14).y - $gameMap.event(16).y) === 1

If anyone could tell me how to edit that so one of the events is the player instead I'd appreciate it! I could use Event Touch but the way the event is set up currently that would take some edits.
Code:
const actor = $gameActors.actor(1);
const eventID = 16;
const gmap = $gameMap;
Math.abs(gmap.event(actor).x - gmap.event(eventID).x) + Math.abs(gmap.event(actor).y -
Math.abs gmap.event(eventID).y)

depending on which event it is used for, you can use instead of "eventID" set to 16
to "this.event".

actor ID number on top to the actor you want. if you want the party leader, use
$gamePlayer.leader() instead.

there are more methodes, depending what the event exacly does and the amount
of events to use, as it can than better done with a notetag on those events.
Code:
const actor = $gameActors.actor(1);
const eventID = 16;
const gmap = $gameMap;
Math.abs(gmap.event(actor).x - gmap.event(eventID).x) + Math.abs(gmap.event(actor).y -
Math.abs gmap.event(eventID).y)

depending on which event it is used for, you can use instead of "eventID" set to 16
to "this.event".

actor ID number on top to the actor you want. if you want the party leader, use
$gamePlayer.leader() instead.

there are more methodes, depending what the event exacly does and the amount
of events to use, as it can than better done with a notetag on those events.
I've tried a few different versions and nothing is working, any idea what I'm doing wrong?

My most recent try was this in a Script conditional:

Math.abs($gameMap.event($gamePlayer.leader()).x - $gameMap.event(16).x) + Math.abs($gameMap.event($gamePlayer.leader()).y - Math.abs $gameMap.event(16).y) === 1

I've tried setting up the variables like you did above, that didn't seem to do anything. I'm assuming I'm missing something but I don't know enough about scripting to know what.
I made a mistake, $gameParty.leader(); or $gameParty.members()[0];

sorry about that, as $gamePlayer does exist, but for different kind of
commands.

using 1 of the above (both targets the leader), should do the trick.
I made a mistake, $gameParty.leader(); or $gameParty.members()[0];

sorry about that, as $gamePlayer does exist, but for different kind of
commands.

using 1 of the above (both targets the leader), should do the trick.
No worries! Sadly I tried those now, and neither seemed to work.

Math.abs($gameMap.event($gameParty.leader()).x - $gameMap.event(16).x) + Math.abs($gameMap.event($gameParty.leader()).y - $gameMap.event(16).y) === 1

I put that in the Script section of a conditional, that's the right place to put it right? Is there a mistake that I'm missing?

Thanks for all your help!
I got it! Did some testing after reading some similar issues.

Math.abs($gamePlayer.x - $gameMap.event(16).x) + Math.abs($gamePlayer.y - $gameMap.event(16).y) === 1

That's the solution! This checks if the player is currently adjacent to an event without using Event Touch, for the strange case if one would need it like mine.
...$gamePlayer.x...

That's the solution!
Yes, that's correct. The reason why @ShadowDragon 's suggestions wouldn't work is everything in $gameParty is returning an actor, and actors don't have coordinates associated with them.

They are also not an event, so saying $gameMap.event(actor ID is simply incorrect syntax (it's supplying a Game Actor as an argument, when it expects a number). And even $gameMap.event(actor ID) wouldn't work correctly, as they're not events.

The $gamePlayer is what represents the character you're controlling on the map.

Original thread: https://forums.rpgmakerweb.com/threads/event-touching-event-conditional.151544/