GameMaker How to save room?

O

orcnaydn

Guest
Hey guys i want to duplicate room then save it but when close game room deleting can help me ?
 

Attachments

Biscotto

Member
Is it necessary to duplicate the room? As far as I can see you could easily assign the room id to your variable.
However, what you're doing is saving a reference to the room id of the given room within a variable. It is normal that when the game is closed, the value of that variable is lost.

You could create a simple .ini save file, and write the value of the variable you want to keep inside the file. After starting the game you can restore the value of the variable by reading it directly from the file.
Manual: Ini Files

PS:
Do not post code photos. Next time use the appropriate rags. You will make your posts more readable. ;)
 
O

orcnaydn

Guest
Is it necessary to duplicate the room? As far as I can see you could easily assign the room id to your variable.
However, what you're doing is saving a reference to the room id of the given room within a variable. It is normal that when the game is closed, the value of that variable is lost.

You could create a simple .ini save file, and write the value of the variable you want to keep inside the file. After starting the game you can restore the value of the variable by reading it directly from the file.
Manual: Ini Files

PS:
Do not post code photos. Next time use the appropriate rags. You will make your posts more readable. ;)
I'm sorry I saw the answer late. What do I need to save in the .ini file? And when i assign room, not assigned just a black screen.
 

Biscotto

Member
What you want to do is create a save of the current room, so that you can retrieve that room at any time, right?
If yes, just save the index of the room (room) (you can safely use an .ini file as I wrote in the previous post. I also linked you the part of the manual that explains perfectly how to write and read on an .ini file), and then, when you open the game, read the index and take the player to that room immediately (room_goto).
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
If yes, just save the index of the room (room)
DON'T get the index of the room. Get the NAME of the room and save that as a string, then when loading use the function "asset_get_index()" on the loaded name to get the room index value. You should NEVER rely on raw index values as references to any asset in the resource tree as these can change at any time. Using them in this way is undocumented behaviour and will bite you in the *ss one day. ;)
 
Top