On my GUI, I want my health int to be displayed. I know you use labels, and I've been looking at the manual but the examples don't seem to be close to what I want. Can anyone give me some pointers?
Well, you have your integer variable in your global script file and then in your repeatedly_execute function you add something like this:
if ( IsGUIOn ( MY_GUI ) == 1 )
SetLabelText ( MY_GUI, MY_LABELNR, MY_VAR );
This first checks if your GUI named MY_GUI in this example is turned on (ie: is visible at the moment) and then if it is visible it sends your var named MY_VAR here to the label on your GUI. You'd need to replace MY_GUI with the number or name of the GUI you have your label on, MY_LABELNR with the object number of your label and MY_VAR with your integer variable...
Hope this helps and by the way I didn't not check that code in ANY way, just wrote it without even having AGS opened, so there might be an error in it.
Yes, neither of them can be defined. All the new codes replaced them now I suppose. I can't seem to find the new way of checking if a GUI is on.
In AGS v2.7, you can check if a GUI is enabled with the GUI.Visible property:
if(gMy_gui.Visible == true) {
Quoteand MY_VAR with your integer variable...
Since labels can only display text strings, you have to convert your integer to a string first:
string tempstr;
StrFormat(tempstr, "%d", MY_VAR);
SetLabelText ( MY_GUI, MY_LABELNR, tempstr);
In AGS v2.7, you give the label a name in the editor and just do
mylabelname.SetText(tempstr);
-
If you're using a GlobalInt to store your health, you could also just set the label's text to @GIx@ where x is the number of the GlobalInt.
Aww, thanks for correcting me there, strazer.
This stuff happens when you answer without trying out anything when you're actually to newb to answer without trying out... ;)
Thanks a lot guys. It worked!