Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Nine Toes on Fri 06/05/2005 09:57:48

Title: Displaying GlobalInts on GUI Labels
Post by: Nine Toes on Fri 06/05/2005 09:57:48
Forgive me, for a few things...

1. I looked around the forum for a similar topic, but found none, even though I could have looked a little more at the very least.
2. I don't remember the EXACT codes I used to try and do what I'm trying to do.

See, what I'm trying to do is display a GlobalInt's value on a GUI label.

Here is a rough guess of the code I have at home:

GetGlobalInt(blah);
string buffer;
StrFormat(buffer, "%d", GetGlobalInt(blah));
SetLabelText(1,9,"%d");


Like I said, it's not the EXACT code I used (because I foolishly forgot to write it down before I left my apartment), but I do know that it doesn't work.  I tried a few other methods, but still no result.

The above code is based on the manual's example for StrFormat(), and with the code I have above, all that I get displayed on the GUI's label is "%d".

Can anyone offer me some pointers?  Perhaps educate me a little more about what the code I have written is REALLY doing?
Title: Re: Displaying GlobalInts on GUI Labels
Post by: Gilbert on Fri 06/05/2005 10:11:47
All okay except one thing (if blah is a well-defined variable with the globalint # in it of course):

GetGlobalInt(blah);
string buffer;
StrFormat(buffer, "%d", GetGlobalInt(blah));
SetLabelText(1,9,buffer);

This is nowhere technical, so I'll move it to the beginners' forum.

Edited: Just noticed, the first GetGlobalInt() is useful for nothing, so I crossed it away.
Title: Re: Displaying GlobalInts on GUI Labels
Post by: Nine Toes on Fri 06/05/2005 10:16:47
Jolly good.Ã,  I'll try it as soon as I get home.

I appreciate it, because I don't really understand too much about string functions and command, therefore, I don't really know how they work.

Thank you very much... and sorry about posting in the wrong forum, I guess I wasn't thinking.

~Mr. Hyde
Title: Re: Displaying GlobalInts on GUI Labels
Post by: TerranRich on Fri 06/05/2005 15:11:26
The variables section in the BFAQ might help you a bit, as well as the "GlobalInts, your friend" section. Too lazy to direct link to them right now. :P
Title: Re: Displaying GlobalInts on GUI Labels
Post by: Nine Toes on Sun 08/05/2005 21:03:18
No need to give me the link, it's in your sig, you shilly sit! ;)  Thanks anyway, man.  BTW, the BFAQ was a big help.

I did what Gilbot told me, and I replaced the %d with buffer, and the code now works just peachy.  And after a little tinkering, I figured out exactly what I was doing.