In need of script to conditional branch check if player is facing this._eventId

Hello, I have searched a bit around and found a similar solution for the ace:
Code:
($game_map.events[?].y - $game_player.y) == 0 && ($game_map.events[?].x - $game_player.x) == -2 && $game_player.direction == 4

Im trying to make a check if player is standing next to and facing this event.
Event does not have fixed position on map.
can you give more info on what you're trying to do instead of how?
There are several possible solutions, but each has their own different requirements and disadvantages depending on what exactly is supposed to happen. So why does the event needs to know this and what should happen when the result is true or not?
Thanks, sure, It it is because i need spawned objects with a active parallel, to check if button CRTL is pressed don't get confused by eachother.
and why do you need that? That is still telling me only how you want to do something, not what the purpose of the entire mess is.
because it is a mess if you want to have multiple parallel processes for the same purpose, a purpose you still haven't described.

what are those spawned events supposed to be?
what is the player supposed to see or do?

From the pieces of what you tell me I strongly assume that you've run into a wrong way with a dead end, and we need to know where you wanted to go originally to tell you how many steps to take back in order to find the correct way.
Agreed. If you have a dozen spawned events and they all have parallel processes that are saying "is the player next to me and facing me", it's going to be laggy, because you have many events all doing the same thing, when only one of them would ever be valid (or more likely, none).

I think instead, you're better off having ONE parallel process event that says "is the tile in front of the player occupied by one of these spawned events? If so, trigger that event to do whatever it needs to do". There are already existing event commands and script calls that will handle those things.
Okay thanks 🙂 I will redo that part and make it another way since its so messy.

but anyhow regarding this little script for ace:
($game_map.events[?].y - $game_player.y) == 0 && ($game_map.events[?].x - $game_player.x) == -2 && $game_player.direction == 4
How would you write this to be valid in MV? possible? Would be interesting to test. Because I have eventdistanceactivate plugin, so it might work without being a mess for this small case.

Very nice of both of you to steer me a little in the right direction. Just started doing gamelogic
($gameMap.event(?).y - $gamePlayer.y) === 0 && ($gameMap.event(?).x - $gamePlayer.x) === -2 && $gamePlayer.direction() === 4
Thank you Shaz 😀 Very nice of you!

Would you please tell me more about how you would set up that check you mentioned with just one parallel process?
Of course Im not asking for you to make me a solution 🙂 Im just wondering how you would go about and make a single parallel
check if player is facing object and is 1 tile near & "control" button command is pressed instead of "enter".
The object is spawned but i have ID of it stored in selfvariable.

I do it all with eventing now thanks to your help, but it's not as optimal as your solution might be.
@Martin as I told you several times above we can help a lot, but we need to know what to do for your game in order to do that.
and you only give tiny excerpts that additionally show that there is too much you hide.

1) what are the events that should trigger? I asked you that before, because without more info about those events we can only tell you to trigger on every event, because we don't know what to trigger and what not
2) what is supposed to happen on that button? what is its function for the player? parallel processes are extremely time-critical, which is why too many of them are a mess - but even a single parallel process can mess up if it is not designed carefully, and that means we need to know what will happen on that trigger to prepare the parallel process for it in case that it matters.
3) prime example that caused this rant:
stored in selfvariable.
This is the first time you even mentioned that you use self-variables. self-variables are a very powerfull add-on that can help in a lot of cases, but that also means that we need to know which plugin you use to create them (there are several different) and what you stored how, especially if it changes the parallel process that needs to check everything.

So if you want our help, please start answering our questions.
we don't write these texts for you to ignore them.
Thank you and I understand 🙂 Im not ignoring your text i just think your question was irrelevant. I sort of only asked for a conversion of a script.
I dont know why my answers arent good enough, but I think its because my limited capabilities with English, this software and coding in general.

When I say: It it is because i need spawned objects with a active parallel, to check if button CRTL is pressed don't get confused by eachother.
You ask what and why. My imidiate answer then is Its a rock, and it can be pickaxed if player press ctrl. But I dont feel thats helping anybody.

When I mentioned the selfswitch, it was to give info that these events already have their ID in a variable. I can of course disable that plugin.

I love all your feedback and help, cant thank enough. 🙂
and it can be pickaxed if player press ctrl. But I dont feel thats helping anybody.
But that was exactly what I was asking for. And contrary to your feeling that info helps a lot.

There are three different reasons why people ask for something like this
- sometimes they want to event battles, which means that the button press triggers a complex and long check on if the enemy event is wounded or killed.
- sometimes they want a special game mechanic to be triggered, like searching for a secret door or digging on the ground with different results
- picking up an item is the rarest but also easiest of these reasons, because it means that only a very few commands are needed when the event is identified.

And yes, most people who ask for something like this want to make an action-battle-system, because most use the action trigger for pickups.


So with that out of the way - I don't have the time to completely write the event for you, but I can give you the basic structure

Make a parallel process common event (needs to be enabled at the beginning of the game or on entering the maps where you want pickup enabled)
conditional branch button pressed to check for the button. If no button pressed, wait(5)
If button is pressed, use two control variables to get the player position
four conditional branches to check facing, adding to the coordinates to get the coordinates of the tile the player is facing
with the tile coordinates, use get location info to get the event ID of the event on that tile

conditional branch on the variable with event ID: if zero then no event
othervise you can use that ID-number to identify if the event is something that can be picked up or not, adding that item to inventory and erasing the event. This is best done with the script equivalents of the change item command and erase event command, you'll find those in a pinned topic in the forum.
I've got to head off to work soon, but a really high level overview is this ...

There are functions in $gameMap that will let you specify an x and y position and direction (in this case, the player's location and facing direction), and will return the x and y positions of the tile in front. So if you want one position away, do it once, and if you want 2 positions away (based on your === 2), do it once, and then use those x and y coordinates and do it again.

Then use another function in $gameMap to see if there is an event at those coordinates. It will return 0 for no event, otherwise the id of the event. It assumes there will only be one event on any given tile.

$gameMap.roundXWithDirection(x, dir)
$gameMap.roundYWithDirection(y, dir)
$gameMap.eventIdXy(x, y)

Once you have that, you just need to see if it's one of your "special" events (maybe give them all a certain name or something).

Original thread: https://forums.rpgmakerweb.com/threads/in-need-of-script-to-conditional-branch-check-if-player-is-facing-this-_eventid.116944/