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.

XP Script Questions

I've been learning Ruby for about two weeks now, but I've run into a couple of problems, which I hope you guys can help me with  :smile:

I had a battle system like the one in Paper Mario, where a representative monster runs around and a fight starts when you touch.  With this, the battles were very easy to avoid because the event had to run straight into the character (or vice-versa).
To fix this, I made 4 variables finding out the Player's X and Y and the Event's X and Y and then compared them with the distance formula in a common event.

...and everything worked out!  With only one monster, anyways.  Apparently, variables can't have multiple values, even when they are called by different events.  So with that long and pointless background story out of the way, here is my first question:  Is there a way to have an array variable that uses the monster name for the array?  I would name the monsters with numbers, and hopefully, I can assign each of them a variable with something like this:  monster_variable[monster_name.to_i]

And a second question!  I have a stamina system set up, but I'm having trouble getting a bar to show up on the map.  I've searched RMXP and RPGRevolution for a script with some sort of bar that shows up on the map, but the only thing that I found required SDK or something.  Can somebody either tell me where to find a script to do this or tell me how to make one?
 

poccil

Sponsor

To answer your first question:

Some time ago, I developed a system that includes a way to assign arbitrary variables to events, including arrays.  This system is called event based variables.  See this thread I created, in particular the paragraph "Event-specific variables" and the explanatory posts I made to that thread.
 

Zeriab

Sponsor

For your first question, no a variable can't contain multiple values at the same time.
You do not need the variable to contain multiple values at once to achieve what you want.
In fact, since you already have a common event it is easy. In the Control Variables dialog select This event under character instead of the specific event. And you are done ^_^
The reason is that when you call a common event, then This event refers to the event that called the common event. More specifically the map event that called the common event..

If you are confused as to what I mean you can look in my demo: http://www.sendspace.com/file/rardvy
I have used the Manhattan distance to calculate distances.

*hugs*
- Zeriab
 
Thank you, this works perfectly!  I actually had something a lot like this (although yours is certainly more efficient then mine) and yours helped me find the problem.  I guess script codes in common events messes things up.  I had this
Code:
$game_variables[25] = 
(Math.sqrt(($game_variables[1] - 
$game_variables[5])**2 + 
($game_variables[2] - 
$game_variables[6])**2))
to calculate the distance, but it would choose a random monster after each battle to delete.  Well anyways thanks again Zeriab, and also thanks to mechacrash and poccil on teaching me a few things in Ruby :)
 

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