I have a question, do the whole game will save the information that the global.pj2 = true? Because when you die you can retry or exit to the menu, this wouldn't make, when you go to the main menu, the information in false?
The game stores whatever information you tell it to store, whenever you tell it to store it.
If you set a global variable to
false in the room creation code of a room, it stays
false until you change it.
If, after it has been set initially, you change its value to
true, it will now be true.
If you then re-enter this room, it will be set to
false again because that's what your room creation code told it to do.
Is like i said. The first room is the menu, and when you score 200 points, nothing happens. I think its doing the same thing like before. How do I change the variable to true without resetting it.
If you tell it to set the variable to
false when entering the menu, it will do that without fail. If you don't want it to do that, don't tell it to do that.
Hence my suggestion of declaring variables "in the
first room of the game that is
not visited more than once", and I mean every part of that literally.
If you have such a room in your game, put the initial declaration in that room's room creation code.
If you don't have such a room in your game, make such a room - as in, an empty room that does nothing aside from running variable declarations and then going to the next room - and never return to it after leaving it.
This method is foolproof and guarantees two things:
- that this code will run before all other code (so that the variables in question exist by the time they are referenced elsewhere)
- that this code will only run once (so that the variables in question don't ever reset)
both of which are vital for what you're trying to achieve.