[Solved] Displaying Variables in GUI buttons/labels

Started by thehivetyrant, Tue 23/02/2010 12:26:19

Previous topic - Next topic

thehivetyrant

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.

Matti

Labelname.Text = String.Format("%d", PlayerHP);

thehivetyrant

Thanks, that worked great, i apologiose for the new thread for this since it did seem very elementary.

...dear watson?  :P

Matti

No need to apologize. It is indeed very basic, but I asked the exact same question 2-3 years ago  ;)

paolo

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.

thehivetyrant

thanks i will check up on that, thanks for the advice

SMF spam blocked by CleanTalk