Variables between rooms ?

Started by coolfozzie, Thu 03/06/2004 02:25:47

Previous topic - Next topic

coolfozzie

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 ?

Gilbert

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;




®2-D2

alternatively, you could use a GlobalInt but I'd also prefer gilbot's version since GlobalInts are limited

foz

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;

TerranRich

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
Status: Trying to come up with some ideas...

SMF spam blocked by CleanTalk