i'm trying to understand why i can't get this tutorial to work can any one help?
i get an undefined token error on the SetLabelText line
here it is )my apologies to the author if im just not reading it correctly..
...........
********************** DISPLAY ENERGY/TIME/POINTS ETC ON A GUI ***********************************************
First you have to make the GUI.
Let's say it's GUI 1.
The energy of the hero is stored in a Global Integer. We will use Global Integer 10.
If we want our hero to start with an energy of 100 we put this in the game_start function :
SetGlobalInt(10,100); // The energy at the beginning is 100.
When we want to add energy we use this script:
SetGlobalInt(10,GetGlobalInt(10) + 10); // Add 10 points of energy.
When we want to subtract energy we use this:
SetGlobalInt(10,GetGlobalInt(10) - 10) // remove 10 points of energy
if (GetGlobalInt(10)>0) {} // If energy is greater than 0 do nothing
else Display ("You are dead"); // else our hero is dead
Then we want to display this on a GUI.
We make two labels in the GUI. On the first (OBJECT 0) we write "Energy"
and on the other (OBJECT 1) we write whatever we want (or nothing )
On the top of the global script we declare the energy string , by writing:
string energy;
In the Global script's repeatedly execute function we write:
StrFormat(energy,"%d", GetGlobalInt(10)); // we're passing the global int's quantity in the string "energy"
SetLabeltext (1,1,energy); //We're displaying the energy points on the object 1 of the GUI 1
That's all. This way you can display whatever you want on a GUI (names. points, money etc)
Hmm are you sure the label's on GUI #1, not other number?
Also check your ';' close each instruction.
Btw, can you copy and paste the actual code you typed in?
SetLabelText (1,1,energy); //We're displaying the energy points on the object 1 of the GUI 1
I'd say...
Quote from: TK on Sat 24/01/2004 14:01:09
SetLabelText (1,1,energy); //We're displaying the energy points on the object 1 of the GUI 1
I'd say...
Cheers TK
that was it, many thanks all for the help
i'd was about to decide i was going mad... :o