[SOLVED]Room Persistence cannot be turned off

B

Borbely-Popescu Robert

Guest
Hello everyone!

I have a problem regarding room persistence.I want to turn the gameplay room's persistence off after the user clicks on the "Back to Main Menu" button that is located in the pause menu(another room which can be reached using a button located in the gameplay room).

My goal is to set the persistent status of the gameplay room to "true" in order for it to resume upon clicking the "Resume" button that is located in the Pause room but if the user clicks on the "Back to Main Menu" button the persistence should be turned off so the next time the user enters the gameplay room,it will start from step 0.

Note that the gameplay room has a "room_persistent = true" line in the creation code so the progress will not be lost upon pausing.

After googling it,I understood that there is a function ( room_set_persistent(room,state) ) that can be used to change the persistence status while not being in the targeted room.Using it while in the Pause room to set the gameplay room's persistence to "false" if the user clicks the "Back to Main Menu" did not work.

On the Tutorial page I have read, there was another method using the "room_persistent" variable while being in the targeted room to change the persistent state to "false" or "true" if the room was already visited and its persistence was already turned on.

The second method I tried was to introduce in the "Back to Main Menu" button's Left Pressed event the following code:

room_goto(Gameplay_room);
room_persistent = false;
room_goto(Start_Room);

so before returning to the Main Menu,the gameplay room is visited and its persistence is turned off but that didn't work either and as soon as the user reaches the Main Menu again and clicks the "Play" button,the gameplay room continues from where it stopped(the moment the user entered the pause menu to exit the gameplay room).

The problem is the gameplay room's persistence is never turned off even if it is visited,manually turned off and then exited.

I hope that you can help me and I thank you in advance for your time and effort :D,
Robert.
 

Jakylgamer

Member
why not just do game_restart() when you hit the back to menu button that should reset the entire game to default state.
 

RangerX

Member
I find it more simple and manageable to not even use room persistence and game restart. You just change rooms and everything resets. Save what you need to save in some global arrays or data structures.
 

TheouAegis

Member
room_goto(Gameplay_room);
room_persistent = false;
room_goto(Start_Room);

If that's all in one code, it wouldn't even work anyway. You'd need a persistent object (as FC said) with a binary state machine. You set the variable to tell it to go to the room. You check if the variable is set to go to the room; if it is, increment the variable and go to the room. If it isn't set to go to the room, is it set to turn off persistence? If yes, clear the variable, turn off persistence, then go back to the main menu.

switch state {
case 1: state++; room_goto(Gameplay_room); break;
case 2: room_persistent = false; state++; room_goto(Start_Room); break;
case 3: state = 0; room_goto(Gameplay_room); break;
}
 
B

Borbely-Popescu Robert

Guest
Thank you all for your help but in order to just dodge the frustrating persistence,I decided to use a Pause menu that doesn't require a room change and I can say its way more controlable.
Thank you again for your time:),I'm gonna change this thread to solved.
 
Top