Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Nishuthan on Sat 14/10/2017 19:39:25

Title: How to display a global int to the status bar (GUI)
Post by: Nishuthan on Sat 14/10/2017 19:39:25
Hi I'm new to ags and I have a few game parameter like money health and knowledge I want to display then in the status bar.is there any way to do that and I also mant to check every time that health !=0 if health = 0   ii want to reset the game.


Thank you
Title: Re: How to display a global int to the status bar (GUI)
Post by: Slasher on Sun 15/10/2017 14:05:40
Make some variable ints for health etc etc and labels to display their values...

eg

Open Global Variables Panel in the editor, right click to add new variable.
Name: Health 
Type: Int
Value: 100 // what ever your maximum health is.

Make a label on the gui and Name it say LHealth_Status

In Global.asc in repeatedly_execute_always()

add the label name like this:

Code (ags) Select

   LHealth_Status.Text=String.Format("%d",Health);


This has a default Value of 100.

If you want to minus 5 from Health simply use this in script where you want it to apply...

Code (ags) Select

// After doing this
    Health -=5;
// This will make your health read 95 (100 -5)


of course it depends how you want it displayed..

Just check the status of Health and run events accordingly..

Code (ags) Select

if(Health <=0) // Health is at or lower than 0
RestartGame();


You could even use a health bar that reduces as it lowers...or rises with more health.

This is a starting place...

Title: Re: How to display a global int to the status bar (GUI)
Post by: Nishuthan on Mon 16/10/2017 17:27:29
Thanks for the help