Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[Filled by various + Zeriab]

Use: (Change the "event id" to the number of the event)
Code:
$game_map.events["event id"].x

$game_map.events["event id"].y

$game_map.events["event id"].character_name
Example, checking event "01":
Code:
p "Event 01 is in tile (#{$game_map.events[1].x}; #{$game_map.events[1].y})",

  "Event 01 graphic is #{$game_map.events[1].character_name}"
 
Ooorz.

I see that my request could be read in two different ways. How bad of me. >_<

I should have written:
'How do I check if any event is on a specific x/y.'

e.g. if there's an event on 038,059.

But thank you for your reply. :X
 
It's nearly identical, just stick the code into a conditional branch. It should be something like this:

Conditional Branch: Script: $game_map.events[id].x == 38 and $game_map.events[id].y == 59

Good luck!
 
EDIT: Regi clicked "submit" before me, -_- but if you still want to read this, go ahead...

your question has been already answered. You see, the thing is that rgss doesn't have an "x/y" position. These are two different variables X AND Y

so, if you want to check that certain event is on 038,059 just write:

@event1 = $game_map.events[1]
@another_variable = false
if @event1.x == 38 and @event1.y == 59
@another_variable = true
else
@another_variable = false
end

see?
If you need more info just reply ;)
 
^

Well, yea, I understand that. ^^

But. I didn't ask for a 'certain event' but for 'any event' (my 2nd post). In that case, what would I put for 'id', since I don't know which event (if any) is on that certain tile (e.g. 038,048)? Doesn't 'id' need to be specified otherwise it's nil and that doesn't work?

I'm sorry if I'm confusing you; I thought my second post cleared things up by referring to 'any event', which should mean that I don't know the ID. Basically I need a way to check for a tile on the map to see if there's an event on that tile or not, and then call that event's character_name. Maybe explaining the purpose would help:

In def move_left etc. I'm putting an if-function that checks for if an event is occupying the tile where you're moving to. If this event has a certain character_name, then the player will move onto the event, regardless of passability. I can do all this, except for that if-function that has to check if the target tile has an event on it or not and what character_name.
 
^

I do indeed have an anti lag script. : d

What happens if there are more than one event on that tile, then passability proceeds as normal (in other words: the if function doesn't go).

Lol, fallen.
 

Zeriab

Sponsor

Not an anti lag, my anti lag. I have seen no other anti lag scripts which has tile-based event look-up.
My anti lag script provides this method for getting an event on a given x, y: $game_map.check_event(x, y)
If you don't have my anti lag script then you probably have to go through $game_map.events and look for matching x's and y's.
 

Zeriab

Sponsor

Feel free to steal it ^_^
Note that if you are not using my anti lag script then it may not be a trivial to steal it.
Note also that you can't really steal it since I have already given permission due to me LGPL'ing the script.
 

Zeriab

Sponsor

Here's a link to the demo: http://www.sendspace.com/file/0up9up
I take that you do not my anti lag script and therefore propose this instead:
Code:
class Game_Map

  def get_event(x,y)

    for event in events.values

      if event.x == x && event.y == y

        return event

      end

    end

    return nil

  end

end
It returns the first event it finds with the given x and y coordinates.

*hugs*
- Zeriab
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top