variable in both rooms doesn't work

Started by saanb, Thu 26/06/2003 02:04:14

Previous topic - Next topic

saanb

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.

Ishmael

I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Gilbert

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.

SMF spam blocked by CleanTalk