Get Location Info Priority

Discussion in 'RPG Maker MV' started by Rink27, Oct 26, 2017.

Thread Status:
Not open for further replies.
  1. Rink27

    Rink27 Veteran Veteran

    Messages:
    222
    Likes Received:
    12
    Location:
    Caribbean
    First Language:
    English
    Primarily Uses:
    RMMV
    Hi.

    I have a scenario where two events can exist at the same location (not by default/initially) and I'm trying to use Get Location Info to identify the ID of the second event that is placed at this location.

    However, I have discovered Get Location Info prioritises the "earlier" event. In other words, if the first event has ID number X and the second event has ID number X+Y, Get Location Info (Event ID) always gives the event ID of the first event because X is less than X+Y.

    Is there a method to prioritise the "older" event (higher numbered ID)?
    OR is there a way to assign an ID number to an event? Because if I can assign a high number to the first event, such that any other event's ID number would always be lower, I should be able to work with that.
     
    #1
  2. waynee95

    waynee95 Lunatic Coder Veteran

    Messages:
    617
    Likes Received:
    502
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    You need a scriptcall for that.
    PHP:
    // Returns all events at a certain x,y position
    var events $gameMap.eventsXy(xy);

    // If there is a second event. (First event would be events[0])
    if (events[1]) {
       
    // Get the second events eventId
       
    var eventId events[1].eventId();
       
       
    // Store it in a game variable
       
    $gameVariables.setValue(5eventId);
    }
     
    #2
    Rink27 likes this.
  3. Rink27

    Rink27 Veteran Veteran

    Messages:
    222
    Likes Received:
    12
    Location:
    Caribbean
    First Language:
    English
    Primarily Uses:
    RMMV
    @waynee95 that you very much. I can work with this.
     
    #3
  4. Rink27

    Rink27 Veteran Veteran

    Messages:
    222
    Likes Received:
    12
    Location:
    Caribbean
    First Language:
    English
    Primarily Uses:
    RMMV
    EDIT: Uh, nevermind. Now it doesn't work as I expect it to. Don't understand how I observed that irregularity before.

    Hmm, something's happening that I don't fully understand @waynee95 . This is the script code I've created inside a conditional if branch command:

    Code:
    $gameMap.eventsXy($gameMap.event(this._eventId).x,$gameMap.event(this._eventId).y)[0] &&
    $gameMap.eventsXy($gameMap.event(this._eventId).x,$gameMap.event(this._eventId).y)[0].eventId()
    !== this._eventId
    The event ID this branch is in is 211. The events I've used to place it at it's location have IDs 192 and 212.
    The script code works for both events, but I thought it would not work for ID #212 since that data should be in [1] not [0] (therefore the script code above should be 211 == 211 and it should fail).

    The logic you presented to me works though. I implemented it another way in a separate parallel event and it can differentiate between [0] and [1] as I understand it.

    @ Moderators; I reported the thread to be closed, but can I postpone that request?
     
    Last edited: Oct 26, 2017
    #4
  5. Shaz

    Shaz Veteran Veteran

    Messages:
    37,360
    Likes Received:
    11,152
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Are you saying "this" event is on a certain spot, and you want to see if there is another event on the same spot and get that event's id? Try putting this in the Script slot of a Control Variables:

    Code:
    var me = $gameMap.event(this._eventId); var them = $gameMap.eventsXy(me.x, me.y).filter(function(evt) { return evt.eventId() != this._eventId; }.bind(this)); them ? them[0].eventId() : 0;
    If the variable is 0, it means there's no other event on the same spot. If it's not 0, it's the id of the other event. If there are more than 2 events on that spot, it will return only one id.

    I don't have MV with me so I haven't been able to test this. It may give errors.

    I wouldn't write any code that relies on events being returned from a function in a certain order.
     
    #5
  6. Rink27

    Rink27 Veteran Veteran

    Messages:
    222
    Likes Received:
    12
    Location:
    Caribbean
    First Language:
    English
    Primarily Uses:
    RMMV
    @Shaz
    Yes, that's right.

    I've been successful with what I want to do. Using the logic I learned above, I check events[0] and events[1]. Both [0] and [1] could never have the same event ID, so if more than 1 event exists at this specific spot, one is bound to have a different ID than the original event ID at that spot. As long as I detect at least one event with a different ID than the original, the condition is true.
     
    #6
  7. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,409
    Likes Received:
    10,415
    First Language:
    English
    Primarily Uses:
    RMVXA
    So, does this mean that you want your Report request to close this carried out, or do you want to leave it open a while longer?
     
    Last edited: Oct 26, 2017
    #7
  8. Rink27

    Rink27 Veteran Veteran

    Messages:
    222
    Likes Received:
    12
    Location:
    Caribbean
    First Language:
    English
    Primarily Uses:
    RMMV
    @Kes I think it can be closed now. I hope a problem doesn't arise. Sorry for any trouble.
     
    #8
  9. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,409
    Likes Received:
    10,415
    First Language:
    English
    Primarily Uses:
    RMVXA
    @Rink27 No trouble at all. Much better to keep it open when you discover an issue than to have to start a new one.

    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

     
    #9
Thread Status:
Not open for further replies.

Share This Page