<disclaimer>
...couldn't find anything on this....
</disclaimer>
By room variables I mean variables you declare at the top of a room script.Ã, Not in the global.
So, I had this at the top:
int rate_trans = 2;Ã, Ã, Ã, Ã, Ã, // static
int rate_opaque = 2;Ã, Ã, Ã, Ã, // static
These were effectivly constants for my room.Ã, the top one represents how many notches to make stuff more transparent per cycle, the 2nd one is the rate to make things less transparent. (ok they are the same at the moment).
I NEVER set these variables except for their initial values as seen above.Ã, I had some strange things occur.Ã, After much hair pulling and debuging I found that rate_trans was = to 100 during run time ?!?!?!?!?!?
One question I have about room variables is when and how often do the variables getting initialized?
Is it possible for some reason that rate_trans never got the = 2 and somehow ended up with a default of 100?
Anyway, this variable was used in room_repeat_exe every 5 cycles.
I have fixed it in the mean time by putting these variable declarations in the function called by room_repeat_exe.Ã, For some reason then, the 2 value stuck.
thanks
I think room variables are only declared when the room loads. In this case, they'd also be reset to 2 everytime.
The '= 2' sticks now, because you're reseting it everytime the function is called - which might cause a problem if you want to make it something other than 2 later on. (I mean changing it during gameplay, obviously it'd be easy enough to change during scripting.) But, if it's a constant value, couldn't you use a #define (or enum) instead of an int?
As to why it didn't stick before - the default value for an int is 0, AFAIK, and I don't see how it could set itself to 100. It'd help if you could show what code you had.
QuoteI think room variables are only declared when the room loads. In this case, they'd also be reset to 2 everytime.
In my experience, room variables are initialized to the specified values the
first time you enter the room. If you change a room variable's value in a script later on, that value will still be there when you re-enter the room.
I tried making #define rate_trans = 2
but then this line 124:
aobj_trans[loop] = aobj_trans[loop] + rate_trans;
gives me:
There was an error compiling your script. the problem was:
in: 'room script'
Error (line 124): Parse error: invalid use of operator '+'
It's
#define rate_trans 2
What it actually does is replacing the word "rate_trans" with the stuff after the word when the game is compiled, so your line was probably made to this:
aobj_trans[loop] = aobj_trans[loop] + = 2;
Also, I think if you're using #defines not ints, it needs to be '+=' for some reason (works for me, anyway, but may be different since you're using an array).
So:
#define rate_trans 2
And:
aobj_trans[loop] += rate_trans;
EDIT: What strazer said, is what I meant.
I think that has nothing to do with whether it's a define or an int, but you can't have two = in there.
You either do
a = a + 2;
or
a += 2;
not
a = a += 2;
Either way the
#define rate_trans 4
worked for me.Ã, Ã, So, thanks all.