Getting Events' Coordinates

Discussion in 'Learning Ruby and RGSSx' started by Erangot, Mar 27, 2015.

  1. Erangot

    Erangot Veteran Veteran

    Messages:
    56
    Likes Received:
    68
    Location:
    Philippines
    First Language:
    Filipino
    Hi there, how do I get an event's x and y coordinates?

    For the player's position I type "$game_player.x" or "$game_player.y" in the event's script.

    But how can I get an event's coordinates where I put the script into?

    ----
    Sorry for the trouble, I'm very much inexperienced with scripting. Thanks in advance.
     
    Last edited by a moderator: Mar 28, 2015
    #1
  2. nio kasgami

    nio kasgami VampCat Veteran

    Messages:
    8,590
    Likes Received:
    2,340
    Location:
    Canada / Quebec
    First Language:
    French
    for the event position 

    $game_event.event.x$game_event.event.y(if I remember I don't know gemini just crash in front of me lol...when I was doing search X_X )
     
    #2
  3. Milena

    Milena The woman of many questions Veteran

    Messages:
    1,282
    Likes Received:
    106
    Location:
    Ireland
    First Language:
    Irish
    Primarily Uses:
    N/A
    Params means these are the parameters in the arguments that you need to fill up, if you're talking about the params in events.
     
    #3
    nio kasgami likes this.
  4. nio kasgami

    nio kasgami VampCat Veteran

    Messages:
    8,590
    Likes Received:
    2,340
    Location:
    Canada / Quebec
    First Language:
    French
    buts I am always curious why exemple for  the comment

    #-------------------------------------------------------------------------- # * Comment #-------------------------------------------------------------------------- def command_108 @comments = [@params[0]] while next_event_code == 408 @index += 1 @comments.push(@list[@index].parameters[0]) end endthey use @params when actually this not really "params" UNLESS this not wield the same signification of parameter in french :/
     
    #4
  5. Quxios

    Quxios Veteran Veteran

    Messages:
    1,055
    Likes Received:
    779
    First Language:
    English
    Primarily Uses:
    RMMV
    Actually Nio I think it's:

    $game_map.events[ID].x$game_map.events[ID].yBut I'm also not completely sure, too lazy to run vxa to check lol
     
    #5
    nio kasgami likes this.
  6. nio kasgami

    nio kasgami VampCat Veteran

    Messages:
    8,590
    Likes Received:
    2,340
    Location:
    Canada / Quebec
    First Language:
    French
    it's vx not vxace Quasi : D
     
    #6
  7. Erangot

    Erangot Veteran Veteran

    Messages:
    56
    Likes Received:
    68
    Location:
    Philippines
    First Language:
    Filipino
    Ahh thanks Quasi it's working for me ;w; All I need to know now is how I'm going to get the coordinates of the "this event", or the event I placed the script into. :D
     
    Last edited by a moderator: Mar 27, 2015
    #7
    NaMosca likes this.
  8. nio kasgami

    nio kasgami VampCat Veteran

    Messages:
    8,590
    Likes Received:
    2,340
    Location:
    Canada / Quebec
    First Language:
    French
    then you replace id by the id of the event and you will obtain "this event"
     
    #8
  9. Milena

    Milena The woman of many questions Veteran

    Messages:
    1,282
    Likes Received:
    106
    Location:
    Ireland
    First Language:
    Irish
    Primarily Uses:
    N/A
    Comments though, is done like this in VX:

    class Game_Event < Game_Character #-------------------------------------------------------------------------- # * Set Event Location #-------------------------------------------------------------------------- def command_108 character = get_character(@params[0]) if character != nil if @params[1] == 0 # Direct designation character.moveto(@params[2], @params[3]) # event x and event y elsif @params[1] == 1 # Designation with variables new_x = $game_variables[@params[2]] # variable number new_y = $game_variables[@params[3]] # variable number character.moveto(new_x, new_y) else # Exchange with another event old_x = character.x old_y = character.y character2 = get_character(@params[2]) if character2 != nil character.moveto(character2.x, character2.y) character2.moveto(old_x, old_y) # from its old value end end case @params[4] # Direction when 8 # Up character.turn_up when 6 # Right character.turn_right when 2 # Down character.turn_down when 4 # Left character.turn_left end end return true endendSo whenever comments or any other params are involved, mostly they are taken from what they are, like this:

    $game_map.events[ID].x$game_map.events[ID].ytechnically, ID is a param.
     
    #9
    nio kasgami likes this.
  10. Another Fen

    Another Fen Veteran Veteran

    Messages:
    526
    Likes Received:
    239
    First Language:
    German
    You can obtain the ID of "this event" by using  @event_id  instead of a static number.

    As an alternative, you can use  get_character(0)  instead of  $game_map.events[@event_id]  too.

    (The only difference is that if the event execution continues after you changed the map, the former will return  nil  while the latter will return the event of the new map with the specified ID.)

    Script commands used in move routes are executed in a different context though, neither  get_character(...)  nor  @event_id   will work there, but you can simply use  self  to access the moving character.
     
    Last edited by a moderator: Mar 27, 2015
    #10
    Erangot likes this.
  11. Erangot

    Erangot Veteran Veteran

    Messages:
    56
    Likes Received:
    68
    Location:
    Philippines
    First Language:
    Filipino
    You are an angel ♥ It's working perfectly now ;w; $game_map.events.... or get_character works fine, whichever of the two that I have used. : D

    Thanks so much! The reason is that my events are cloned from another map and the player chooses where he/she will till the soil, so I couldnt manage to use a static number to set where the event should be placed. Here's how it looks like as of now.

    [​IMG]

    [​IMG]

    [​IMG]
    Thanks again .. I guess I wouldn't need to ask regarding the tile_id any longer. And and thanks to Milena for the info regarding params : )
     
    Last edited by a moderator: Mar 28, 2015
    #11
    NaMosca and nio kasgami like this.

Share This Page