Hi, I would like to display custom variables that are changing in real time.
Also in a non blocking manner.
I can't work out how.
If it was like @myvar@ on a gui button, then I'd be able to but, it ain't.
Could you fill me in on it?
As well, can I ask this...
Is Wait(1); A special rendition of the wait() Global function?
I keep seeing Wait(1) in loops and so on, yet, to make the game "wait up",
you would use something more like Wait (80);
which according to the manual would result in a wait of 2 seconds.
cheers
To display variable value in a GUI label, you can do something like:
StrFormat(text, "The value is %d", value);
(where text here is a string variable and value is an int variable)
Then in the repeatedly execute function, use SetLabelText() to set the appropiate label text to the string text.
QuoteIs Wait(1); A special rendition of the wait() Global function?
No, this is HOW you use the Wait() function. You MUST provide an integer parameter to tell the function how many game loops to wait.
Under default setting an AGS game runs at 40FPS (can be changed via SetGameSpeed() ), so Wait(1) will wait for 1/40 second, and Wait(40) for one second normally.
Hi, thanx for the info. I now understand that Wait(1) means wait one game loop which makes sense, but I'm still confused about how to display a variable.
Like, say I declare my variable to be...
int power = Random(100);
Then how would it get fed into
StrFormat(text, "The value is %d", value); ??
I also looked at SetLabelText command
it seems like it wants the name of the variable to be displayed,
but I really don't quite grasp it.
Like, I don't want to display a string variable, just a number,
so the mention of string variable confuses me somewhat.
Could you help me a bit more with this please.
you have to convert an int variable to string in order to display it in a gui label, something like:
int power = Random(100);
string buffer;
StrFormat(buffer, "Power: %d", power);
SetLabelText(GUI,#,buffer);
Then, if the 'power' variable is 57, the label will show "Power: 57"
Ok thank you Proskrito and Gilbot V7000a for your help.
Much appreciated.
Is there any other way to display custom variables in a non-blocking way apart from via a GUI button label? Or is this method the only way to go?
You may also use DisplaySpeechBackgound(), but that may not be what you really want. So, using a GUI seems to be the best way.
Overlay another possibility, but GUI the best.