[RMMV] Script for Event and Actor Map X,Y

Discussion in 'RPG Maker MV' started by Jory4001, Oct 29, 2015.

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

    Jory4001 Veteran Veteran

    Messages:
    80
    Likes Received:
    17
    Location:
    Canada
    First Language:
    English
    I looked through the Script Call Equivalent post and I did a few searches and didn't find the whole answer to what I was looking for.

    I found $gameMap.regionId(x, y); on the Script Call Equivalent page, but I need to know the variable of the Actor's Map X/Y as well as getting an Event's Map X/Y

    and also, how would a conditional look to compare the two region ID's to see if they are the same, with an else statement as well?

    This is what I am looking for:

    If RegionID(Actor X, Y) = RegionID(Event X, Y) then

    Else

        if RegionID(Actor X, Y) = RegionID(Event X-1, T) or RegionID(Actor X, Y) = RegionID(Event X+1, T)... ext to check the adjacent map tiles

        else

        End Conditional

    End Conditional

    Thanks in advance!
     
    #1
  2. Shaz

    Shaz Veteran Veteran

    Messages:
    37,184
    Likes Received:
    11,052
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    You can do this with events, you know - Control Variables will let you get the player's or an event's coordinates - so you'd need 4 of them.

    However, in a conditional branch, you can use the following in the script section to see if they are on the same tile - replace # with the event id (EV003 would be 3, not 003):

    Code:
    $gamePlayer.x === $gameMap.event(#).x && $gamePlayer.y === $gameMap.event(#).y
     
    #2
    l3m35 and GGZiron like this.
  3. Jory4001

    Jory4001 Veteran Veteran

    Messages:
    80
    Likes Received:
    17
    Location:
    Canada
    First Language:
    English
    Just to clarify, I am comparing the region ID's the Actor and events occupy, they may be in 2 different parts of the map but on the same Region ID

    So for the condition I would need:

    $gameMap.regionId($gamePlayer.x, $gamePlayer.y) === $gameMap.regionId($gameMap.event(#).x, $gameMap.event(#).y)

    Why three "===" ?

    What is used for "OR"

    Do I need to include the ";" at the end of the script in the event script box?

    Thanks for your reply!
     
    #3
  4. Sn0wCrack

    Sn0wCrack Veteran Veteran

    Messages:
    82
    Likes Received:
    48
    Location:
    Australia
    First Language:
    英語
    Shaz has given the way of finding if the Player and Event are on the same tile.

    3 equals signs is the same as 2 equals but also checks data types, so normally 0 == false would evaluate to true, but 0 === false would become false.

    For your purposes all you need to do is replace the actor's X and Y with $gamePlayer.x and $gamePlayer.y

    and the event's X and Y with $gameMap.event(#).x and $gameMap.event(#).x

    (Make sure you change # to the event id)

    However I'm unsure as to what you're actually trying to achieve with this to be honest, as what you have setup checks if a player and the event are on the same tile graphic.
     
    #4
  5. Jory4001

    Jory4001 Veteran Veteran

    Messages:
    80
    Likes Received:
    17
    Location:
    Canada
    First Language:
    English
    I was experimenting with a Tiled Lighting system.

    I would have 1 event for each tile visible on the screen, in my case 22x14, so 308 events. Each room would be given a different Region ID, when  the player enters Room with Region ID 1, then any other rooms with a different Region ID still visible on screen would be blocked out by changing the graphics on the events, only allowing you to see in the room you are currently in.

    I ran into a few issues that I could have worked around but came up with a new way to do the same with only 1 event for each room instead of 308 events moving with the character lol.

    Either way it was nice to learn the above!

    Thanks!
     
    #5
  6. CameronCalvert

    CameronCalvert LazyCam Veteran

    Messages:
    48
    Likes Received:
    4
    First Language:
    English
    Primarily Uses:
    N/A
    I know this is late guys but I can't find it anywhere. Is there a way to make a code for THIS event? Like $gameMap.event(#) But instead of an event ID is there a way to tell it to make the action on THIS event? As I want multiple instances on my map but I don't want to have to make a seperate code for every single event.
     
    #6
  7. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,133
    Likes Received:
    10,301
    First Language:
    English
    Primarily Uses:
    RMVXA

    CameronCalvert, please refrain from necro-posting in a thread. Necro-posting is posting in a thread that has not had posting activity in over 30 days. You can review our forum rules here. Thank you.



    This thread is over 2 years old. In addition, your query is different from that of the OP's. In an active thread this would count as hi-jacking a thread.

    Please post a new thread, setting out fully what it is you want to achieve.
     
    #7
Thread Status:
Not open for further replies.

Share This Page