I want to make text on a GUI display the contents of a string or variable. How can I do that?
Using a label (http://www.adventuregamestudio.co.uk/manual/GUI%20Label%20functions%20and%20properties.htm).
labelname.Text = String.Format("%d", health_points); // integer
labelname.Text = player_name; // string
And RTFM ;)
Thanks. I only read the section under "other features", I didn't think to check in the scripting section :-[
There are loads of problems not explained in the tutorial.
Most of the easy ones can be solved by browsing through the scripting section or using the forum search.
It's also possible to do a full text search of the manual.
I didn't want to be rude, but if people ask questions here that are plainly answered in the manual, they get a RTFM. :)
Is there any way to do this with using the global variables from the global var editor.
Quote from: keyes on Wed 17/09/2008 20:52:49
Is there any way to do this with using the global variables from the global var editor.
Sure. You create a string variable in the global variable editor, and set the label to the value of the global variable, like this, whenever you want the label text changed:
lblLabel = vGlobalString;
This, however, is absurd and stupid, because you now have two variables representing the exact same thing. There's really no reason to do this, as you can set the text of the label from any script and save yourself a bunch of time.
Well I was wondering if you can put something in the text box for the label that will refer to one of my global var.
ex. my var states the location.
I have a gui with a label to state my location at all times. what do i enter into the text that makes it state my variable
You can't do that; you have to do it manually.
If the label's text is gonna change at every room change, it's best to use the global script's on_event function (http://www.adventuregamestudio.co.uk/manual/TextScriptEvents.htm).
You won't need a variable in this case.
Just add a custom property (http://www.adventuregamestudio.co.uk/manual/Custom%20Properties.htm) (type: String, name: "location", default value: "") and enter the location's name for every room.
Add this to GlobalScript.asc:
function on_event(EventType event, int data) {
if (event == eEventEnterRoomBeforeFadein) labelname.Text = Room.GetTextProperty("location");
}
oh, ok thanks for the help
"Error: (line 42) Undefined token 'labelname'"
This wouldn't have to do with me using 2.72, would it?
of course you have to change 'labelname' to the name of your label ::)
If you just copied the code, then you need to re-name "labelname" to the actual name of the label you're using.
[Edit]
Beaten by Smash