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.

Cannot figure out...Comments in Events?

Okay, well I just want to start off saying that I'm sorry for bothering you people with yet another request of the exact same type, but I just haven't gotten anything to work.
I've looked at all these threads:
http://www.rmxp.org/forums/index.php?topic=12341.0
http://www.rmxp.org/forums/index.php?topic=4425.0
http://www.rmxp.org/forums/index.php?topic=8170.0

Basically, what I've been trying to do is have an array that contains all the events on the map with comments that read "blah" and also contains their x, y, id, and distance from the player. It should continuously update.
Now, I've gotten it to look like what's in the third thread I linked to(BlueScope's topic). However, when I use
Code:
p $tevents   #$tevents is the array I use
It just outputs "[]".
If anyone can help with this, I would really appreciate it!  :thumb:
 

khmp

Sponsor

It outputs "[]" because the array is empty. You can also do this to check although they will all indicate the same thing.
Code:
print $tevents.empty? # will print true if it is empty and false if it isn't
print $tevents.size # will print the amount of items in the array

In regular code comments are ignored. Are you trying to print the comment like what they are discussing in the first two threads you have linked? Or are you trying to fill tevents with the events on the map? Because $game_map.events holds all that information inside a hash already. No need to make an array unless you need some kind of special ordering put in place.

Well anyway to put something inside the array you need to use indexing or push or the "<<" operator or something to at least place the event inside the array. Otherwise it will be empty. Maybe I'm missing the question.
 
Exactly, I've been trying to make an array of the events and it will be sorted from least distance from the player. I'm not trying to print anything, I was just using that as an easy way to check if it was working. If it was, it would show some sort of data other than []. As far as I can see, the problem is the code that checks the events for the comment, since the array is never being filled. I'm using chaosg1's script towards the bottom of the third topic, with $beacon changed to $tevents, and I do have a
Code:
    $tevents << event.id
but I don't think event.id is right for that.


EDIT:
Okay, I took that out and messed with things a bit, and I've finally got it. I'm just looking around for how to sort hashes now. Looks like this is resolved. Thanks!  :thumb:
 

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