Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: thehivetyrant on Tue 23/02/2010 12:26:19

Title: [Solved] Displaying Variables in GUI buttons/labels
Post by: thehivetyrant on Tue 23/02/2010 12:26:19
HI,
   I have set up a global variable of 10 and created a GUI button and am trying to make the text show '10' from that global variable.

PlayerHP = 10

I have tried @PlayerHP@ and %PlayerHP but they just show the text but not the variable value.

Any help would be appreciated. thankyou.
Title: Re: Displaying Variables in GUI buttons/labels
Post by: Matti on Tue 23/02/2010 12:43:53
Labelname.Text = String.Format("%d", PlayerHP);
Title: Re: Displaying Variables in GUI buttons/labels
Post by: thehivetyrant on Tue 23/02/2010 12:47:28
Thanks, that worked great, i apologiose for the new thread for this since it did seem very elementary.

...dear watson?  :P
Title: Re: Displaying Variables in GUI buttons/labels
Post by: Matti on Tue 23/02/2010 12:51:14
No need to apologize. It is indeed very basic, but I asked the exact same question 2-3 years ago  ;)
Title: Re: Displaying Variables in GUI buttons/labels
Post by: paolo on Tue 23/02/2010 18:22:34
One small point to add: if you haven't already, do look up Format in the AGS manual, as %d will work only for integer variables. If you want to display strings, floating-point numbers, etc, you need a different symbol (or symbols) following the per cent sign.
Title: Re: [Solved] Displaying Variables in GUI buttons/labels
Post by: thehivetyrant on Wed 24/02/2010 11:54:47
thanks i will check up on that, thanks for the advice