Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Thu 03/06/2004 02:25:47

Title: Variables between rooms ?
Post by: on Thu 03/06/2004 02:25:47
I'm trying to use a variable between two rooms to track weather or not the player uses an elevator so that when the 2nd room loads, the ags knows the player used the elevator and runs an elevator opening animation. I tried to declare the variable in the global script but the room script could not recognize it. What am I doing wrong ?
Title: Re: Variables between rooms ?
Post by: Gilbert on Thu 03/06/2004 02:33:49
Variables declared in the global script are initially local to the global script, that is, they're not global to the game.

To make them accessible via the other room scripts, you have to export the variables in the global script after declaration and then import them on top of a room script (if you want them accessible by all the rooms, just import them in the script header), For example:

Global Script:
int blah, haha;
export blah, haha;

Room Script:
import int blah, haha;



Title: Re: Variables between rooms ?
Post by: ®2-D2 on Thu 03/06/2004 10:23:48
alternatively, you could use a GlobalInt but I'd also prefer gilbot's version since GlobalInts are limited
Title: Re: Variables between rooms ?
Post by: foz on Thu 03/06/2004 20:08:14
If you do what Gilbot said but its better to do this as it allows all rooms to access that variable.....


Global Script:
int elevator;
export elevator;

Script header:
import int elevator;
Title: Re: Variables between rooms ?
Post by: TerranRich on Fri 04/06/2004 05:12:18
Quote(if you want them accessible by all the rooms, just import them in the script header)

I do believe he already said that. :P