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.

Displaying variable values such as hp,mp, e.t.c...

Hey everyone, i was wondering if anyone had a useful script for displaying the numerical values of variables onto the screen. For example, lets say you had a hero called Bob or whatever and you wanted to simply display somewhere on the screen his Current HP / Max HP. Back in the day with rpgmaker2k and 2k3 the easiest way to do this was by using a bunch of character sets to store the individual digits of his current hp and his max hp. (ones, tens, hundreds, thousands...) Now with scripting avaliable in xp, i'm sure displaying those values are made 10 times easier just i haven't really learned much of ruby language yet. Any sort of help would be much appreciated. Thank you so much!
 
well kind of like a hud but with no template/background. In other words i want to be able to reuse the script in just about any place in the game where you have to display the values that are stored into the variables, whether its displaying the numbers in a stats menu, displaying the amount of gold you have in a weapon shop, displaying the damage dealt on an enemy when you attack him in battle, or even something simple like displaying the amount of people in your group or whatever.

The best way to describe it is something where i can just open up an event editor and do something like this.

display_value(0,400,10,20,"HP: {Bobs_Current_HP}")

where the parameters are (x coordinate, y coordinate, width, height, variable you want displayed)
 
you need a bitmap object to draw a text. In the case of a window, the bitmap is called contents. So if you want to display something in a window, you need to use this line
Code:
self.contents.draw_text(x,  y, width, height, text, alignment)
you can display any variable you want in a string by using the #{ } format; for exemple, the string "Party Size: #{$game_party.actors.size}" will display the size of your party
 
First off, thanks a bunch Dargor for all the help. I appreciate you taking your time to help me out. A quick question reguarding your response. Is self.contents.draw_text already a built in function? Thanks again so much. You are awesome!
 

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