Detect Change of Direction when standing on event.

Hi, this is probably really basic, but I couldn't find a solution.

I want my character to notice he can search the barrels when he is in the square below them, I put in this Player Touch Event:

Conditional Brance: Play is Facing Up

   Show Balloon Icon: Player, Exclamation, Wait

   Text: blabh blah blah

  Else

Branch End

 

 

So if I approach from the south, move onto the even while facing up: perfect. All is good.

 

If I approach and walk into the event from the Left or Right. Nothing happens. Excellent.

 

but if I am standing on the event and I change direction to face Up - nothing happens.

 

Is there a way for a change in direction to re-trigger the event?

 

Sorry if this is a really simple question, I've had VX Ace for 3 days now and I'm still learning and reading tutorials.

 

 

EDIT: Updated title for clarity.
Not really, with conditional branches and such. Here's what I would do (keep in mind I'm not long out of bed and my mind is still groggy - I may come back and say it's a stupid idea 😉 )

Give your event three pages.

First page.

No conditions.

Trigger is Player Touch.

Command is Control Self Switches A = ON.

Second Page.

Condition is Self Switch A = ON.

Trigger is Parallel Process.

Add commands as follows:

Conditional Branch: Player is facing UP Show Balloon Icon: Player, Exclamation, Wait Text: blah blah blah Control Self Switches B = ON.Else Conditional Branch: Script: $game_player.x != $game_map.events[@event_id].x || $game_player.y != $game_map.events[@event_id].y Control Self Switches A = OFF. EndEndWait 5 framesCopy that script line exactly as I have it there - don't substitute anything.Third Page.

Conditioned by Self Switch B = ON.

No other changes.

This will make the event detect when the player walks onto it, then go into a loop of checking if the player is facing (or turns) up, or if the player walks off the event - at that point it will either show the balloon and text then disable itself, or it will go back into a waiting state until the player walks onto it again.
Its possible to do this with Global Variables and just a Script Box.

Parallel Event:

# Store initial value

Script: $player_d = $game_player.direction if not $player_d

# If Player Direction changes

Conditional Branch -> Script:  $game_player.direction != $player_d

  # Do your eventing stuff here

End

When you leave the room or the event is all done and wont be used again, use another Script Box to set $player_d to nil so that it can be dumped by Ruby's Internal Gabage Collector.  The eventing can get fairly complex, but this shouldnt be too difficult to detect any changes in Player Direction.
you didn't read the request properly. He doesn't really want to monitor for player changing direction (despite that being exactly what's implied by the title) - he wants to monitor for the player standing on a specific tile and facing up, which includes moving onto that tile from a different direction and then turning to face up.


Your event would not do that.
Conditional Branch -> Script:


$game_player.x == 16 && $game_player.y == 24 && $game_player.direction == 4


# Do Stuff


End


16 and 24 are XY Coordinates of tile to be moved to from 4 which is Left.


Shaz, you seem to address a lot of my posts as "not solving the problem". I dont want to fix all these problems for everyone. What I am trying to do is to teach these people how to think about the problems so they can solve them for themselves by introducing concpets they can understand. Give a man a fish and you feed him for a night. Teach a man to fish and you feed him for a lifetime.
oh, wow. I'm really sorry to burst your balloon, but your suggestions are just not very good. Neither of the two you've provided here will solve the OP's problem.


And if you're not trying to fix their problems, why post? They have asked for a solution. They want a solution.


Let's look at each one you provided.

Parallel Event:


# Store initial value


Script: $player_d = $game_player.direction if not $player_d


# If Player Direction changes


Conditional Branch -> Script: $game_player.direction != $player_d


# Do your eventing stuff here


End


When you leave the room or the event is all done and wont be used again, use another Script Box to set $player_d to nil
Why are you using a global variable? Not needed, and not a good idea.


Why are you setting the variable to the player's direction and then immediately testing to see if it's the same as the player's direction? It always WILL be, because you've just set it to be the same before doing the check


The conditional branch will NEVER evaluate to true.


Putting that aside (assuming when the player does change direction, that that branch will be true) ...


That logic will be run continually while the player's on the map (if we assume parallel event means an event on the map and not a common event) so EVERY TIME the player changes direction, that code is going to trigger.


It doesn't care where the player is on the map


It doesn't care what the new direction is


And the suggestion of using ANOTHER script box to set $player_d to nil? Why? Why not just set a self switch that controls a new page so the event doesn't run anymore? If you have one event that is repeatedly setting $player_d to nil, and another event that is repeatedly setting $player_d to the player's direction, they are going to conflict, and the test will be run right after you set it to the player's direction.


None of this addresses the question actually asked, and that's the point I was making - you appear to have read the thread title, and provided a solution, without reading the original post to see what the OP was actually trying to achieve.


So, in your revised post after you read the original requirement ...


You have shown how to hardcode the x and y values for checking. What if they move the event one tile to the left or the right? What if they want to copy it and have the same thing happen in several places? My solution says to compare the player's location with "this event's" location. If they move the event, it will still work. If they copy it and paste it 15 times, it will still work.


And I just don't understand this:

16 and 24 are XY Coordinates of tile to be moved to from 4 which is Left.
That's not what the OP asked for either. They asked for a way to tell, if they are standing on a certain tile, if they are facing up. Up is 8. They are not necessarily moving.


If your objection is merely teaching them how to do it themselves, some people just want the answer so they can get on with their game. The OP has a single post and joined the forum yesterday. He said he only got Ace 3 days ago. It's save to assume he may already be overwhelmed with the amount of stuff he has to learn. I provided steps to follow, told exactly what to put in, and then afterwards explained the logic of how those event pages all work together.


Don't get me wrong - your eagerness to help people is appreciated. But you need to make sure you're thinking things through, answering the question they asked, and that you get it right. The times when I correct you (or anyone else, or when anyone corrects me), it's because those things haven't been done. And sometimes you give solutions for engines you don't even have access to (and scripting solutions at that).
@Shaz: Youre right. I am obviously not welcome here.


Piss off, and goodbye. I wont be coming back.
G'day. Thanks for the replies. Sorry about the argument.

Shaz, putting in your script worked first time. Awesome, thank you very much. I'd like to learn from it, so correct me if i am wrong... I'm going to try and puzzle this out, so bear with me...

Event Flow Process:

EventPage1: I touch this and it triggers EventPage2 to run.

EventPage2: Triggered as soon as I touch the event and then it keeps running as a parallel process. This event does all the work.

EventPage3: After the conditions are met, the event is pushed to this page where it stops.

Question 1: When the event his page 3. Does the Parallel Process stop as well or should it be stopped and disposed of somehow?

so all the work happening in Page2: 

If the Player is facing up then do my stuff, then set the switch so EventPage3 gets triggered.

If the Player is not facing up then run the script.

If the script is run, it then turns off the switch so that EventPage1 is triggered again restarting the whole process.

This is where my brain is getting stuck. If EventPage2 is running as a parallel process, so it keeps running over and over: Why doesn't it identify that I change direction while standing on that tile? Shouldn't it get to the end of the event content and start again? IF it is doing this, how come when I change the direction when standing on that tile, it doesn't start the eventpage2 again and the conditional check identify that the player is now facing up?

I must have something wrong in my understanding.

Based on the fact that I am missing something, before I try and understand the script, any chance you could confirm my understanding as written above and tell me what I'm doing wrong?

Cheers,

`Andy
Only one event page can be active at a time. If page 2 is running and you face up, it activates page 3. This means page 2 stops running, and page 3 is active. There is nothing to make page 3 inactive.


If you want this to happen EVERY time you step on the tile and not just the first time, make the following changes:


- remove page 3


- on page 2, instead of Control Self Switch B = ON, change it to Control Self Switch A = OFF


That means, once you step on the tile and face up, the message will show, then page 2 will be made inactive and page 1 active, and it will go back to waiting for you to step on the tile again. This also means, if you don't move off that tile but change direction a few times (only possible if you're in a corner, I believe), it won't show the message again - it will wait for you to step off and on again.


If this isn't doing what you're after, you might need to be more specific about what happens after the message has displayed the first time - what do you want the event to do afterwards, and what do you want it to do if you walk away and come back again?
It does EXACTLY what I want it to - also, it is in a corner 😀

I've been trying to puzzle out exactly what the script does:

$game_player.x != $game_map.events[@event_id].x || $game_player.y != $game_map.events[@event_id].y

so if I am right...

$game_player and $game_,map.events are global variables for my player and the event on the map.

but what is the .x and the .y?
$game_player, obviously, is the player character.


$game_map has all the settings for the map. $game_map.events is an array containing all the events on the current map. @event_id is the id of the current event, set in Game_Interpreter (so if your event is EV015, @event_id is 15). Using @event_id means it will always check "this event", so if you want to copy the event and paste it 15 times, each one will always reference itself - you don't need to change any of them. So $game_map.events[@event_id] is "this event".


.x and .y are simply the x and y tiles that they are currently on.


What it's saying is if the player and event are not on the same x tile, or they are not on the same y tile, it means the player has moved off the event. This triggers the event to stop monitoring for the player's direction and go back to the previous state of waiting for the player to walk on it again 🙂
HOLY GLOB! I have been wracking my brain over this for ages. I'm sooooo glad i found this!

EDIT: Okay I lied, I can't get this to work haha. I'm about to rip my hair out 🙁
All I need is for an event to check which direction once I am standing on it, and keep checking it, (in case I turn to face that direction) just like the initial post.

But once the player faces that direction, I need it to transfer them to a new area. I tried using the script code and it just pulls up a syntax error window. Is there any info I can provide for more assistance?

Edit #2: Oh my good gravy, I'm so dumb today, I found this on google and it's not even for rpg maker MV haha. I'm a mess. Any chance this has been addressed on RPGMV somewhere?
Necro-post notice: Ringtale Games

You will need to search the MV Support forum, as it is less likely that an MV user will be casually browsing Ace Support and see your question. If there's nothing in MV, then make a new thread and ask.

Moderator note: Closing

Original thread: https://forums.rpgmakerweb.com/threads/detect-change-of-direction-when-standing-on-event.36477/