Help with text on Labels?

Started by beomoud, Wed 14/11/2007 15:41:04

Previous topic - Next topic

beomoud

I have looked everywhere for this. I'm trying to display values on GUI labels but i get errors. I'm currently using the manual but i've come to understant that it is obsolete at some points. My code is this
==============================================================
String Stre;
String Cons;
String Nimb;
String Inte;
String Char;

 
String.Format (Stre, "%d", Strength);
String.Format (Cons, "%d", Constitution);
String.Format (Nimb, "%d", Nimbleness);
String.Format (Inte, "%d", Intelligence);
String.Format (Char, "%d", Charisma);

lblNumber1.GetText (Stre);
Display("%s", Stre);
//Label.SetText (4, 2, Cons);
//Label.SetText (4, 3, Nimb);
//Label.SetText (4, 4, Inte);
//Label.SetText (4, 5, Char);

===========================================================

It returns the message: Error (line26): Undefined token "lblNumber1"

-What is wrong with my code, could i make it simplier, it doesn't seem to find my label's script name and i can't find it either

-Also is there a manual that includes all the new  changes, sometimes i find the right code in here instead of the manual, do i  have an older versio?



Khris

You don't have to declare all those Strings, you can do:

lblNumber1.Text=String.Format("%d", Strength);

Make sure that the label is actually called "lblNumber1", not "Number1". Either change the scriptname or the code so both match (labels don't use a lbl prefix automatically, the manual is a bit misleading there).
A label's scriptname can be changed in its properties window in the GUI editor.
Plus, if you start typing the scriptname and the auto-complete window doesn't show, something's bound to be wrong; it's usually a good indication of wrong naming.

Set.../Get... have occasionally become obsolete if CJ made the field public, so in this case you can directly write the String to the .Text field of the label.

If you've downloaded AGS2.72, it came with the most recent agshelp.chm.
The latest Beta includes some changes to the manual but those are mostly regarding tutorials or similar stuff.
Command syntax was mostly kept since the new beta is almost exclusively a revamp of the editor.

beomoud

Thanks man... really you are great, it worked perfectly, thanks

SMF spam blocked by CleanTalk