Am I using this wrong?

W

Wild_West

Guest
I'm almost ready to make levels for my game now that my enemies, player stats, inventory, shopping and environmental objects are all finally done. But I need to reset the playable levels once the player reaches a warp point at the end of the stage so they can visit the area where they spend points to power up and continue through the game.
I read about room persistence in the manual and according to it, you can't set the persistence of a room you've already visited.
Then it says to switch off persistence "you should go to that room, and THEN switch persistent off" except before that it says :
"With this function you can change (or set) the persistence of any room in your game except the current one."

So I'm just confused as to what they mean, but all I need to do in my game is reset all the playable rooms to false every time I go back to map select.
Another object controls the next playable stages unlocking in the map select room.

My question is ,
How do I use room_set_persistent(); to change rooms I play through back to how they were initially after I change room to map select ONLY? (Or basically any room that's not a playable stage)
Because I tried using this code below to do it in a test project but my room1 kept resetting after I came back from room4 anyway.

This is in room start vent of my level controller object. Level Controller IS persistent.
if(room == starting_room)
{
room_set_persistent(room4,false);
room_set_persistent(room1,false);
}
 
A

anomalous

Guest
I would just do what the manual says and see if it works.

NOTE: This function will NOT work to switch off persistence if the room has already been visited! A persistent room, once visited, is held in memory and to switch off persistence you should go to that room and set the room_persistent variable to false and then exit the room again.

When you go to map select, have pause/blackout and go into each room, set to persistence = false, and exit the room to the next one, repeat, then back to the map room and unpause/show the menu.
You may be able to throw up a background/black or whatever, to hide what you are doing.

Maybe the first point is that it cannot set persistence if you are already in the room. But it can flag non-persistence, because hopefully that kicks in only when you leave the room...
 
W

Wild_West

Guest
I would just do what the manual says and see if it works.

NOTE: This function will NOT work to switch off persistence if the room has already been visited! A persistent room, once visited, is held in memory and to switch off persistence you should go to that room and set the room_persistent variable to false and then exit the room again.

When you go to map select, have pause/blackout and go into each room, set to persistence = false, and exit the room to the next one, repeat, then back to the map room and unpause/show the menu.
You may be able to throw up a background/black or whatever, to hide what you are doing.

Maybe the first point is that it cannot set persistence if you are already in the room. But it can flag non-persistence, because hopefully that kicks in only when you leave the room...

I haven't actually gotten around to a paused game state yet. So I guess that'll be next on my list before I get started on this.
But is what you mean by "It can 'flag' the persistent but not 'set' it, that it can have the variable value change it just won't actually take effect until it's exited the room?"

Because I know how I can do the blackout thing if that's the case
 

TheouAegis

Member
It means if you go to room4 when it's persistent, go back to the main menu, set room4's persistence to false, then go back to room4, room4 will still be the way you left it. Supposedly according to the manual, if you then leave room4 and go back to it, it will still be the same because you couldn't turn off persistence from another room. So according to the manual, you'd go to room4, then go back to the main menu, then set a variable like "reset=1", go back to room4, check if reset is set, set room4's persistence to false, set reset back to 0, then go back to the main menu.

But I'm just going off what the manual seems to say. I never used persistent rooms.
 
W

Wild_West

Guest
It means if you go to room4 when it's persistent, go back to the main menu, set room4's persistence to false, then go back to room4, room4 will still be the way you left it. Supposedly according to the manual, if you then leave room4 and go back to it, it will still be the same because you couldn't turn off persistence from another room. So according to the manual, you'd go to room4, then go back to the main menu, then set a variable like "reset=1", go back to room4, check if reset is set, set room4's persistence to false, set reset back to 0, then go back to the main menu.

But I'm just going off what the manual seems to say. I never used persistent rooms.
Hmm, well I'll keep experimenting then until I get it going the right way.
 
A

anomalous

Guest
All I meant was that based on what the manual wrote, changing a room to "not persistent" will have no effect in the room you are in AT THAT TIME. It will only affect it once you leave. But really it's just important for you to go to each room you already set as persistent, change it (from within that room) to NOT persistent, then exit that room, for it to take effect.
Hope it works for you.
 
W

Wild_West

Guest
All I meant was that based on what the manual wrote, changing a room to "not persistent" will have no effect in the room you are in AT THAT TIME. It will only affect it once you leave. But really it's just important for you to go to each room you already set as persistent, change it (from within that room) to NOT persistent, then exit that room, for it to take effect.
Hope it works for you.

I see so it's basically just the same idea as refreshing a web page.
The page has to reload everything and then it shows whatever updated changes were made.
That's a lot clearer lol
 
W

Wild_West

Guest
All I meant was that based on what the manual wrote, changing a room to "not persistent" will have no effect in the room you are in AT THAT TIME. It will only affect it once you leave. But really it's just important for you to go to each room you already set as persistent, change it (from within that room) to NOT persistent, then exit that room, for it to take effect.
Hope it works for you.

Well I set up my attempt at switching room persistence but my warp object keeps taking me back to the starting room after I get to the bonus area room, which is wrong I should be going back to the previous area. and then go to the upgrade area and THEN the map select room if I don't have any gate keys in my inventory.

This is controlled by 2 objects as warps won't be in EVERY area like the shop or map select room.

Information about object: level_controller
Persistent: true
Parent:
Children:


Create Event:
execute code:

loading = false;
load_time = 100;

Other Event: Room Start:
execute code:

//Reset the last room we were in to not persistent ONLY if the next room to start is the map room.

if(loading == true)
{
room_goto(room1);
load_time --;
room_set_persistent(room1,false);
if(load_time <= 0)
{
room_goto(starting_room);
loading = false;
load_time = 100;
}
}


This is all that's in my warp hole upon collision event with the player


///Warp Hole Network
switch(room)
{
case upgrade_room : room_goto(starting_room); break;

case room4 : room_goto(room1); break;

case room1 : room_goto(upgrade_room); break;
}



//Warp to bonus area
if(room == room1)
{
for(search = 0; search < 6; search ++; )
{
if(menu_object.held_items[search,1] == key)
{
room_goto(room4);
}
}
//room 4 will act as the bonus room for a level in the actual game.
}
Any idea where I went wrong here?
 
Last edited by a moderator:
W

Wild_West

Guest
It means if you go to room4 when it's persistent, go back to the main menu, set room4's persistence to false, then go back to room4, room4 will still be the way you left it. Supposedly according to the manual, if you then leave room4 and go back to it, it will still be the same because you couldn't turn off persistence from another room. So according to the manual, you'd go to room4, then go back to the main menu, then set a variable like "reset=1", go back to room4, check if reset is set, set room4's persistence to false, set reset back to 0, then go back to the main menu.

But I'm just going off what the manual seems to say. I never used persistent rooms.

Well never mind the set_persistent function there's a room_persistent variable built in that does the same job much easier lol
I'm not sure why they have both
 

TheouAegis

Member
One is intended for setting persistence from outside the room. Just because you can't disable persistence from outside a room doesn't mean you can't enable it.
 
Top