Joined: Feb 8, 2014
The haiku master。
Posted: Jun 24, 2016 04:36 PM
Msg. 1 of 3
so as part of a campaign I've been rehashing I need to check if a global variable has been set to three. now if that was just one script using the variable it would be fine, however I have a main script where the variable is defined and then three other scripts that add +1 to the variable at various times, the main script then waits until the variable is three before continuing. this is logical and should work, however sapian cannot compile the scripts as the three outside scripts do not recognise the global variable as a real variable.
here's how I've defined it:
(main script (endgame):
(global short all_marines 0)
(script startup endgame
(set (all_marines) (+ (all_marines) 1))
These scripts all do the same thing
back to the main script:
(sleep_until (= (all_marines) 3)
can anyone see whats wrong here?
Joined: Jan 22, 2006
Apparently public enemy number 1?
Posted: Jun 24, 2016 07:18 PM
Msg. 2 of 3
Don't put parenthesis around the global variable name; it believes its something it can execute. (set all_marines (+ all_marines 1)) etc.
Also, since you say you've made them multiple scripts (I assume you means .hsc files), they compile in alphabetical order; if something that uses the global is compiled before the global is compiled, it will fail, since the global really doesn't exist yet. Its easiest using one HSC file.