Generally the way I check to see which direction one thing needs to orient in order to be facing another thing is to check the relationship between their x and y values. You can do this through code or eventing (by setting variables' values to that of the player's/event's positions, and subtracting/comparing them). In Ace I believe the built-in vars for x and y are simply "x" and "y" (although if your map wraps it can become more complex).
I would write it as:
dist_x = $game_map.events[2].x - $game_player.x
dist_y = $game_map.events[2].y - $game_player.y
if ((dist_x.abs >= dist_y.abs) and (dist_x >= 0)) # object is further away in x-dir, and object is to the right of the player
direction_needed = 6
end
if ((dist_x.abs >= dist_y.abs) and (dist_x < 0)) # object is further away in x-dir, and object is to the left of the player
direction_needed = 4
end
if ((dist_x.abs < dist_y.abs) and (dist_y >= 0)) # object is further away in y-dir, and object is below the player
direction_needed = 2
end
if ((dist_x.abs < dist_y.abs) and (dist_y < 0)) # object is further away in y-dir, and object is above the player
direction_needed = 8
end
Then finally you'd plug in the line you'd written:
if ($game_player.direction == direction_needed)
Do things, such as show a message "Hey, you! Stop looking at me!"
end
That's because the "scope" of variables (such as direction_needed) defined within a Script block is limited to that script block. You are trying to work with the direction_needed variable outside of that Script block.
Either save the variable to a Game Variable (you can do this with a line like $game_variables[250] = direction_needed ) and then use that game variable in the Conditional Branch later, or move your whole Conditional Branch check back to the Script block (run that line to get a 'true' or 'false' value and save that to a Game Switch with a line like $game_switches[208] = ((blahblahblahconditionalcheck)) ).
Like an enemy that only attacks if you look at it?