Hello everyone!
I'm currently trying to figure out a script that will determine the event ID that I'm looking for and store the ID in variable 27 using CTB's NearestEventMV plugin. This way I can call the event in another script call in order to change the event priority when needed. I won't always know what the event ID is going to be, which is why I need to store it in a variable.
If it was just one event at a time, that would be fine. My issue is that there are situations where multiple events could be an equal distance away from the player. I need it to be the event that's equal to
I did find some good help on this forum post and based my current script call off of that. However, it doesn't appear to be changing the variable like I thought it was going to.
Here's my script I was attempting to run:
Clearly this isn't correct, but I'm not sure why. I've been racking my brain most of the day trying to come up with a solution and I feel like the answer is right in front of my face, but I can't see it. Any help would very much so be appreciated!
Thank you! 🙂
I'm currently trying to figure out a script that will determine the event ID that I'm looking for and store the ID in variable 27 using CTB's NearestEventMV plugin. This way I can call the event in another script call in order to change the event priority when needed. I won't always know what the event ID is going to be, which is why I need to store it in a variable.
If it was just one event at a time, that would be fine. My issue is that there are situations where multiple events could be an equal distance away from the player. I need it to be the event that's equal to
$gamePlayer.x && $gamePlayer.y-1I did find some good help on this forum post and based my current script call off of that. However, it doesn't appear to be changing the variable like I thought it was going to.
Here's my script I was attempting to run:
JavaScript:
var events = $gameMap.eventsByDistance('DekuNut');
events[0]._eventId // first closest
events[1]._eventId // second closest
events[2]._eventId // third closest
events[3]._eventId // fourth closest
if (events[0].x === $gamePlayer.x && events[0].y === $gamePlayer.y-1) {
$gameVariables.setValue(27, (events[0]._eventId))
}
else if (events[1].x === $gamePlayer.x && events[1].y === $gamePlayer.y-1) {
$gameVariables.setValue(27, (events[1]._eventId))
}
else if (events[2].x === $gamePlayer.x && events[2].y === $gamePlayer.y-1) {
$gameVariables.setValue(27, (events[2]._eventId))
}
else (events[3].x === $gamePlayer.x && events[3].y === $gamePlayer.y-1) {
$gameVariables.setValue(27, (events[3]._eventId));
Clearly this isn't correct, but I'm not sure why. I've been racking my brain most of the day trying to come up with a solution and I feel like the answer is right in front of my face, but I can't see it. Any help would very much so be appreciated!
Thank you! 🙂