|
Post by ismavatar pls read on Mar 11, 2004 8:58:17 GMT -5
How do I make my variable ammo stay the same when i change rooms instead of it having reset to zero? I did not use any script.
Eg. I already have collected 100 ammo in my 1st room. But when I go to the 2nd room, the amount of ammo is reset back to 0. I want it to be the same as when I left room 1.
Note from boards: user, please register and be active, thank you.
|
|
|
Post by Xenith on Mar 11, 2004 16:22:45 GMT -5
well im no master of gm but i know your supposed to use a global variable instead of a normal one. ie. if your variable is called ammo then rename it to global.ammo im not sure if thats right but test it out
|
|
|
Post by IsmAvatar on Mar 11, 2004 17:40:38 GMT -5
Xenith, you are somewhat correct. global variables stay the same throughout rooms. a local variable will be erased from memory, and calling it would return an error (unless you have treat unitialized variables as 0 ticked). so, one way is to use global variables. another way, is to make sure that the object that has the local variable does not set it in his create event, and is created at the start of each room, because setting a variable also resets it. to avoid this, do it in the game start event. Also, if it's a local variable, then the variable will be erased for the new room. to avoid this, make the object persistent. this makes the object appear in every room thereafter at the same position. there's other more advanced ways, but I won't go into them.
|
|
|
Post by LanceHeart on Mar 11, 2004 22:40:35 GMT -5
Just make sure you don't have something that resets your variable to 0 before starting a room. That can always cause a huge problem when you put the command in something that spawns all the time in every room.
|
|