How to check event's X and Y in a script form?

Hello 😀

The title says what I'm searching for 🙂

How can I use an event's X Y instead of variables? I can't really put variables since I'm having 30+ events that would need to know X and Y. I'm having trouble to explain, but if you need more details, I can try to explain more

Sorry for my english and thank you!
$gameMap.eventIDXy(x,y) should do it, also you should probably bookmark: //docs.google.com/spreadsheets/d/1-Oa0cRGpjC8L5JO8vdMwOaYMKO75dtfKDOetnvh7OHs/edit#gid=0
It is the script call list for MV.
No. That returns the id of the event that is at that x/y location on the map.

To GET an event's x or y location, it's just event.x and event.y - but then you also have to define event. If it's a command on an event and you want to check its own location, it'd be $gameMap.events(this._eventId).x and $gameMap.events(this._eventId).y but if it's a single event and you want to check the location of multiple events, it would be different. You would need to tell us more about what you're trying to do, and where you're trying to run it from, before we can give you the exact command.
@Shaz Right sorry.

I'm trying to do a money system. It's supposed to be picked up from the ground when an event goes over it. Any event can do, as in that map with 30+ event of gold, only 2 specific event can trigger, so it should be fine. But I cannot store specific locations of gold into variables, sincee it would require 60+ variables. I think I explained myself, but if you need more help, I can try to explain better. Thank you 😀
Are the gold events going to be in fixed locations on this map?
nope, random locations. 🙂
And where are you running this check? Are your gold events parallel processes that are checking if there's another event in the same location? Or are you putting the check on your other events that move over the gold? Or do you have a single parallel process that's monitoring the position of ALL events?

I bet we can make this SUPER easy for you, but you need to be more forthcoming with information - unless we can see exactly what you're doing (ie - show us screenshots of the event/s that have all the logic), we're only guessing and offering suggestions. If you show us everything, exactly as you have it, we can give you a full solution.
@Shaz Sorry for this inconvenience :/
I'll try my best to explain this time.

Event System Needed: Coin System

How it should work: Players (2 players) can pick up the coins, then store that coin to a variable, that variable is now +1

Why I need help: these coins is 30+ coins that will spawn at random locations using GALV's Event Spawn Plugin (doesn't affect the actual eventing too much). They don't exist until the command says so. Since there are too much coins, I would prefer to not have to use variables to store locations of these coins.

Why I can't use Player Touch: These players are movable events.

How it could work: It would greatly save processing if there would be 1 event activating when a player touches an event called ''Coin'', then check what player did get the coin, and then do the appropriate command based on what player picked it up. It wouldn't need to check if the event was a player since they are the only events that can touch the coin.

Here's a picture on what I'm trying to do (ignore these magnificient drawing skills ;p):

2ptcayr.jpg


So in short:

- Player 1 or 2 (event) touches coin
- Commands run when event goes on it
-Coin disappears
- Coin get added in variable Coin Count

I hope I did good for the explanation, I did my best and I hope I was clear enough. Again sorry, I'm not always specific on what i want and I find it awesome that you guys are patient with me 🙂

Thank you!
Two players? You have a two-player script, and this is not a case of events moving over other events?

In that case why don't you just set the coins to Player Touch and do a +1 to the variable in the event commands?

If your players ARE events, then you must have some kind of controller so the events move when the different players hit their keys. In that case, you can add a command after the move to see what events are at that location, and if one of them is a coin - if it is, +1 to the variable and remove the coin.
@Shaz These players are events, and they are controlled with Input.isPressed()

I don't really know how to check if the event is on a coin :/
Can you please help me a little bit furter 😛

Thank you 😀
The event spawn script still allows you to have code inside the spawning events, right?
@Trihan yes, it doesn't affect coding that much. The only difference is that coins do not exist until I say they do.
bump
Hmm, does the event spawner give the event an ID on creation? I have an idea but it requires that you're able to identify coin event IDs.

Wait, actually, no it doesn't. Hang on a sec.

Edit: This should do what you're looking for, put it in as a script call in your parallel process event.

Code:
var coinEvents = $gameMap.events().filter(function(event) { return event.event().name === 'coin' && !event._erased; });
var playerEvent = $gameMap.events().filter(function(event) { return event.eventId() === 5; })[0];
coinEvents.forEach(function(coin) {
  if (playerEvent.x === coin.x && playerEvent.y === coin.y) {
    $gameMap.eraseEvent(coin.eventId());
    // code for scoring here
  }
});

Make sure all your spawned events are called "coin" and replace the 5 with whatever your player's event ID is (and obviously add a second one for player 2, but the conditional will be the same).
@Trihan Thank you! It should do the trick!

Just 1 last thing, how do you make the command to turn on the self-switch of that event (coin)?
$gameSelfSwitches.setValue([$gameMap.mapId(), coin.eventId(), 'A'], true);
Thanks! My problem is now solved!

Original thread: https://forums.rpgmakerweb.com/threads/how-to-check-events-x-and-y-in-a-script-form.74817/