Printing out GetGlobalInt contents

Started by R4L, Mon 21/11/2005 15:30:17

Previous topic - Next topic

R4L

Can I take the values from a GetGlobalInt(1); and print them onto a label on a GUI?

Ashen

Yes you can, the same way you'd display any int:
Code: ags

string temp;
StrFormat(temp, "%d", GetGlobalInt(1));
lblLabel.SetText(temp); // Where 'lblLabel' is the label's script name


(Assuming you're using 2.7, of course).
I know what you're thinking ... Don't think that.

R4L

I'm using 2.61, so this code may be different.

Ashen

Only the last line, as far as I remember. Instead of having the script name, you need to use:
Code: ags

SetLabelText(GUI, CONTROL, temp);


Where GUI is the name/number of the GUI (e.g. if it was on the Inventory GUI, it'd be INVENTORY or 2), and CONTROL is the GUI Item number of the label.
I know what you're thinking ... Don't think that.

R4L

Oh, ok thanks. I will try it out after school! :)

strazer

You can also set "@GIx@" as the label's text, where x is the number of the GlobalInt.

Manual: Tutorial -> Setting up the game -> Global Messages

Ashen

Or that, yes.
I always forget about it, as it never seems to work for me - although I know it does in general.
I know what you're thinking ... Don't think that.

R4L

#7
Ok I will try these out. Thanks alot! :=

EDIT: I tried the @GIx@ one and it doesn't work. BTW Ashen, would I put this in my GUI script or under repeatedly execute?

EDIT AGAIN: God i'm stupid, I must not have read the part where strazer said "where x is the number of the globalint."

SMF spam blocked by CleanTalk