RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Get event name at (x,y)?

0 Members and 1 Guest are viewing this topic.

*
Resident Cloud
Rep:
Level 91
Im currently making a small edit to game_player. the goal is to only allow the player to get off his ship when hes at a port event. Im attempting to do this by inserting PORT in the event names of ports which my script would then check using regular expressions.

the only problem is i need to check the existence of an event at the place the character wishes to land and then determine its name.

How do I do this?

heres an image to explain things clearer:


red = player
blue = event

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Hmm, there might be some built in way to do it. A problem is that even when you retrieve the event, you're out of luck because the event name is located in a private class variable. So here, try this:

Code: [Select]
#========================================================================
# ** Game_Event
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#      new method : data
#========================================================================

class Game_Event < Game_Character
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Data
  #----------------------------------------------------------------------------------------------------------------------------
  #  Allows public, read-only access to the class variable, @event
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def data
    return @event.dup
  end
end

#========================================================================
# ** Game_Map
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#      new method - check_for_events
#========================================================================

class Game_Map
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Check for Events
  #      x : the x coordinate of the square you want to check
  #      y : the y coordinate of the square you want to check
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def check_for_events (x, y)
    # Make an array to store all events on that square
    events_on_square = []
    # Determine which, if any, events are located at [x, y]
    @events.each_value { |i| events_on_square.push (i.data) if i.x == x && i.y == y }
    return events_on_square
  end
end

That will return in an array all of the events located at [x, y]. Keep in mind it only returns the base data since that is all you asked for. The code below will return everything related to the event, but to get to the base data you will need to use the code event.data

Code: [Select]
#========================================================================
# ** Game_Event
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#      new method : data
#========================================================================

class Game_Event < Game_Character
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Data
  #----------------------------------------------------------------------------------------------------------------------------
  #  Allows public, read-only access to the class variable, @event
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def data
    return @event.dup
  end
end

#========================================================================
# ** Game_Map
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#      new method - check_for_events
#========================================================================

class Game_Map
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Check for Events
  #      x : the x coordinate of the square you want to check
  #      y : the y coordinate of the square you want to check
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def check_for_events (x, y)
    # Make an array to store all events on that square
    events_on_square = []
    # Determine which, if any, events are located at [x, y]
    @events.each_value { |i| events_on_square.push (i.dup) if i.x == x && i.y == y }
    return events_on_square
  end
end

Also, data is probabably a poor name for the method, but you can play around with it.
« Last Edit: March 05, 2008, 12:05:07 AM by modern algebra »

*
Resident Cloud
Rep:
Level 91
thanks once again :D

i <3 you.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
 :-[ Don't be. I just checked and discovered that the feature to check for events on a square is already built in:

$game_map.events_xy (x, y) does pretty much the same thing as the second code.

So really, all you need is the modification to Game_Event.

*
Resident Cloud
Rep:
Level 91
doh :( i tried using that but forgot to mention it and how i was trying to use it. however it still works now:D which got me out of a sticky spot