I'm sure I must have done something stupid or missed something obvious, but have some variables that aren't behaving.
I can change the variable from 0 to 1 in one room. When I enter any other room it's at 0 again. There is no code anywhere that changes the variable to 0. While I'm still in the room it also shows up as 0 on the status line (which is updated in the global repeatedly_execute) while the character says that it's 1.
This happened with an int variable, so I changed to a bool and it worked. Now I've made a couple more bool varaibles and they're behaving the same way.
I have around 100 Strings, ints and bools in all, have I hit some kind of limit?
I'd appreciate any help you could offer!
Where and how have you defined these variables?
I thought I'd forgotten to mention something!
In the global script header, like this to begin with:
int catStat=0;
Then I wondered if this meant that I was setting the int to 0 ever time a new room script was run, so I changed the troublesome variable to say this in the global header:
int catStat;
And I added this in game_start:
catStat=0;
Which didn't seem to help.
Just as I thought. :)
If you define variables in the script header, separate variables are created for the global script and each room script. Changing the variable's value from within a room script thus doesn't affect any of the others.
To create a global variable that you can use outside the global script, you have to define it in the global script, export it and then import it into the script header:
// global script
int catStat;
export catStat;
// main script header
import int catStat;
Thanks Strazer! I guess when my way seemed to work it didn't depend upon variables being altered in more than one room.
You're welcome! :)