Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: saanb on Thu 26/06/2003 02:04:14

Title: variable in both rooms doesn't work
Post by: saanb on Thu 26/06/2003 02:04:14
i scripted a room with this one variable then later, i decided i needed that variable in another room too so i put int something at the top of the global script. then i used the variable in the other room and there was an error there so it didn't work. grrr.
Title: Re:variable in both rooms doesn't work
Post by: Ishmael on Thu 26/06/2003 16:09:41
Global Ints... manual....
Title: Re:variable in both rooms doesn't work
Post by: Gilbert on Fri 27/06/2003 04:44:13
Variables declared in the global script aren't automatically made global, they are still local to the global script. You need to export a variable in the global script so it can be imported back in the room scripts for access.

For example if you declare:
int blah;
in the global script and you want it to be accessible by other some room scripts you need to put first to the bottom of your global script:
export blah;
For rooms which need to access that variable, put on top of the room script:
import int blah;

You can also use GlobalInts for it, just check out the GetGlobalInt() and SetGlobalInt() script functions from the manual.