Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Thu 05/05/2005 17:36:34

Title: Question regarding SetLabelText
Post by: on Thu 05/05/2005 17:36:34
I am attempting to put a label on my GUI displaying an integer stored in a GlobalInt. However, as SetLabelText only allows me to set a string and not a variable I am slightly lost. I attempted to get around this by setting a GlobalString in the Global script like so:

SetGlobalString(1,GetGlobalInt(1));

Unfortunately this didn't work. I have read the manual but cannot find antything telling me how to get around this. Can anyone help me?
Title: Re: Question regarding SetLabelText
Post by: Scummbuddy on Thu 05/05/2005 17:57:01
string amount;
amount = GetGlobalInt(1);
SetLabelText(2,3,amount);

maybe? I'm unable to check it, as I am not near my AGS. It may have a problem since I'm not typecasting, though.

------------------------
Sorry, forgot to tell you about:
StrFormat
StrFormat (string destination, string fmt, ...)

Processes the string FMT in the same way as the Display function does (ie. replace %d and %s with values of variables), but instead of displaying it on the screen, puts the result into DESTINATION.
NOTE: You cannot use the DESTINATION string as one of the format arguments, or the results will be unpredictable. (ie. StrFormat(buffer, "%s", buffer); won't work)

Example:

int health=10;
string buffer;
StrFormat (buffer, "%d", health)

will fill buffer with the string representation of the value of health.
See Also: Display
Title: Re: Question regarding SetLabelText
Post by: on Thu 05/05/2005 20:18:51
Ta, that seems to work :)