46
Technical forum / Cannot get globals to be "globals"
« on: April 01, 2009, 12:42:25 AM »
Later
I think I have worked it out it seems you have use the global prefix prior to using the variable in other scripts, that's fine, but my thinking was that if you re-used the global prefix you would re-initialise the variable - perhaps you can confirm these assumptions for me.
Probably doing something very obvious incorrectly here. I am trying to use globals for games state, and they don't appear to work, I have looked at the thing a number of times, and even used the globals that are automatically initialised, but they don't seem to be visible to other procedures
this is the debug list
00:21: Compiling script 'scenes\greendale\scr\pat.script'...
00:21: Error@line 26: Variable 'Stategreendale' is referenced but not defined
00:21: Compiling script 'scenes\greendale\scr\pat.script'...
00:21: Error@line 62: Variable 'SpeechTrigger' is referenced but not defined
00:21: Compiling script 'scenes\greendale\scr\cu_background.script'...
00:21: Error@line 4: Variable 'SpeechTrigger' is referenced but not defined
00:21:
00:21: Shutting down...
00:21: Shutting down scripting engine
and the offending code is in three scripts, the two globals Stategreendale ( system generated) and SpeechTrigger are initialised in screen_init.script.
global Stategreendale;
global SpeechTrigger = 0;
in the script oat.script both are assigned values
Stategreendale.Visited = true; - line 26
SpeechTrigger = 1; - line 62
in the script cu_background.script
if (SpeechTrigger ==1);
is there some switch I need to set for globals to work ?
I think I have worked it out it seems you have use the global prefix prior to using the variable in other scripts, that's fine, but my thinking was that if you re-used the global prefix you would re-initialise the variable - perhaps you can confirm these assumptions for me.
Probably doing something very obvious incorrectly here. I am trying to use globals for games state, and they don't appear to work, I have looked at the thing a number of times, and even used the globals that are automatically initialised, but they don't seem to be visible to other procedures
this is the debug list
00:21: Compiling script 'scenes\greendale\scr\pat.script'...
00:21: Error@line 26: Variable 'Stategreendale' is referenced but not defined
00:21: Compiling script 'scenes\greendale\scr\pat.script'...
00:21: Error@line 62: Variable 'SpeechTrigger' is referenced but not defined
00:21: Compiling script 'scenes\greendale\scr\cu_background.script'...
00:21: Error@line 4: Variable 'SpeechTrigger' is referenced but not defined
00:21:
00:21: Shutting down...
00:21: Shutting down scripting engine
and the offending code is in three scripts, the two globals Stategreendale ( system generated) and SpeechTrigger are initialised in screen_init.script.
global Stategreendale;
global SpeechTrigger = 0;
in the script oat.script both are assigned values
Stategreendale.Visited = true; - line 26
SpeechTrigger = 1; - line 62
in the script cu_background.script
if (SpeechTrigger ==1);
is there some switch I need to set for globals to work ?