How to display general, changing text in status bar GUI

Started by pietakio, Mon 06/08/2012 19:22:49

Previous topic - Next topic

pietakio

Hello All,

I am making my first game and already understand that a changing text field can be placed in the long grey "status bar" GUI using commands like:
@HOTSPOT@ or @SCORE@ ...BUT

What I would like to know is how to display a general entity in the status bar. For instance, let's say I define new global integers (I want more score-like variables to stand for things like money, health, time, etc) and I want them to keep updating their values in the status bar display field at the top. How do I do this? I've tried playing around and dug into a lot of tutorials but haven't been able to find out...

Thanks so much for your help.

Khris

Change the text whenever the values change and put it on a label.
Code: ags
// GlobalScript.ash
import void UpdateStatusText();

// GlobalScript.asc
void UpdateStatusText() {
  lblStatus.Text = String.Format("Money: $%d - Health: %d% - Time: %d:%d", player_money, player_health, time_hour, time_minute);
}

// example code in room
  Display("You find a hundred dollar bill.");
  player_money += 100;
  UpdateStatusText();


If the time display is going to change every minute or second, just put the call to UpdateStatusText(); in repeatedly_execute in GlobalScript.asc. That way the label is updated constantly.


SMF spam blocked by CleanTalk