I'm trying to detect the location of an event to prevent events from moving onto each other when both have through turned on. The reason they're like that is so the player can stand on them to interact and move them to a chosen location, but they can't walk off the area (which would be possible if the player had through on instead). This is the script I'm using to do that, but I don't know how to use the result from it after that.
For reference, that calls this from Game_Map
I tried using the script to change another variable and check that with a conditional branch, but when there wasn't an event, it crashed the game since the variable's result wasn't a number.
I also tried another way with this and placed it directly into a conditional branch:
Using that made it work, but if it wasn't true, then the action for it not being true didn't happen.
Is there a way to have it be used directly in a conditional branch and return true if there's an event instead of returning the event id when it gets one?
Code:
$game_map.check_event(
$game_variables[13],
$game_variables[14])
For reference, that calls this from Game_Map
Code:
#--------------------------------------------------------------------------
# * Get Designated Position Event ID
# x : x-coordinate
# y : y-coordinate
#--------------------------------------------------------------------------
def check_event(x, y)
for event in $game_map.events.values
if event.x == x and event.y == y
return event.id
end
end
end
I also tried another way with this and placed it directly into a conditional branch:
Code:
def check_for_event(x, y)
for event in $game_map.events.values
if event.x == x and event.y == y
return true
end
end
end
Is there a way to have it be used directly in a conditional branch and return true if there's an event instead of returning the event id when it gets one?