Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Da_Elf on Sun 24/12/2006 14:34:32

Title: GUI label error [SOLVED]
Post by: Da_Elf on Sun 24/12/2006 14:34:32
whats wrong with this script.
lblStatus.Text = GetGlobalInt ("daytime");

in my glabal script ive already set the code "int daytime=1;" (without quotes)
but when i go to test the game i get the error.
--
Error (line 211); type mismatch; cannot convert 'const string to 'int'
--
Title: Re: GUI label error
Post by: Ali on Sun 24/12/2006 14:41:41
This should work:

lblStatus.Text = daytime;

A variable that you've defined yourself isn't a Global Int. Global Ints are identified by integer numbers rather than strings (which is what caused: cannot convert 'const string to 'int'). They're useful because you can alter them from within dialogue scripts.
Title: Re: GUI label error
Post by: Da_Elf on Sun 24/12/2006 14:46:32
im using this in each rooms section "repeatedly execute" as a script. since the int was defined in the global script i get an error saying "undefined symbol 'daytime'"

when i move this code to the global script and place it right below where i state int daytime = 1 i get an error saying "parse error: unexpected 'lblStatus'"
Title: Re: GUI label error
Post by: Ali on Sun 24/12/2006 14:51:33
Try putting the line in repeatedly_execute in the global script.

If you do want to use this line in a room script rather than the global script, you need to export and import the variable:

At the end of the global script:
export daytime;

In the Global Header script:
import int daytime;

EDIT: SSH is absolutely right. You listen to him, now. I don't know how I didn't spot that.
Title: Re: GUI label error
Post by: SSH on Sun 24/12/2006 14:54:45
The problem is, ints or global ints or whatever are of type "integer" and a label text is type String. So you need to do:

lblStatus.Text = String.Format("%d", daytime);

For easier globalints, try my DeNGVaT module.

And do you actuially have a GUI label called "lblStatus"? ANd does the previous line have a semicolon?
Title: Re: GUI label error
Post by: Da_Elf on Sun 24/12/2006 14:58:13
ok. i did the suggestion of exporting the int so that i can use it in a rooms repeatedly execute script and i think it has the exact same effect as using getglobalint ("daytime") since I'm now back to getting the error "type mismatch; cannot convert 'int' to 'string*' is it possible that i cant use int to define a label?

EDIT thanks SSH It worked perfectly. yup there is the label called lblStatus...i decided also to keep it in the global repeatedly_execute area