Saving based on the room the player is in with Drag and Drop

So, i've been working on making a platforming game using Drag and Drop in Gamemaker 2 Studio. I'm struggling with a save system. The sort of system i want is if the player is in a certain room, the game saves automatically. For example, once the player gets to a new world, saving it so that when they load the game, they can go right back to that world's level select screen.

Any help you can offer is appreciated. ^-^
 

Bayesian

Member
You should make something generic that takes the player to new worlds so you can reuse it. When you trigger it it should check if the save file exists. If it doesn't it makes one. If it does it edits it. All you need to write to it is the world or room name. Then make a new starting room and load it first when you run the game. In the room's creation event it should also check if the file exists and if it does open and read the the world name then go to that worlds level select screen.

The ini file stuff should be all you need. This is their format:
Code:
[Section]
Key = Value
All you need to store and read is something like this:
Code:
[Player]
World = rmWorldOneLevelSelect
 
You should make something generic that takes the player to new worlds so you can reuse it. When you trigger it it should check if the save file exists. If it doesn't it makes one. If it does it edits it. All you need to write to it is the world or room name. Then make a new starting room and load it first when you run the game. In the room's creation event it should also check if the file exists and if it does open and read the the world name then go to that worlds level select screen.

The ini file stuff should be all you need. This is their format:
Code:
[Section]
Key = Value
All you need to store and read is something like this:
Code:
[Player]
World = rmWorldOneLevelSelect
Alright, just one quick question, For where you put player, do i use my player object for that slot?
 
I'm not quite sure what you mean. Where do you want to put the player and when? And what slots?
When you put player, did you mean i put my player object there? Or what did you mean? and what i want to do is just save the player so they can load in on the level select screen of the world their currently on, and save their progress.
 

pipebkOT

Member
https://docs2.yoyogames.com/source/_build/3_scripting/4_gml_reference/file handling/ini files/index.html

go read the manual, ini files are the solution for you, you need to save the room where the player is gonna be loaded. the x and y position, etc

you need to create a save object, in it you put the code about saving(in the create event)

you need to use ini_open and ini_write_real or ini_write_string

example save code:
Code:
ini_open("savedata.ini");
ini_write_real("Player,"currentworld", room)
ini_write_real("Player","coins","global.coins")
ini_write_string("Player", "name", global.Name);
ini_close();
you create the save instance when the player is trown back to the world level select.




you create a load game object that loads you in the last room saved

example load code
Code:
ini_open("savedata.ini");
global.world=ini_read_real("Player,"currentworld", 0)
global.coins=ini_read_real("Player","coins","0")
global.name=ini_read_string("Player", "name", "");
ini_close();
 
Also, Do i have to repeat the same process for each individual level select room? Like do i have to make new objects for each world save, or do i just do the same code under the same save object?
 

pipebkOT

Member
@GamingDragomachina

Use gml, try to learn how to use it . Not drag n drop .
Gml Is more easier and less tedious.
Also the majority of people on this forum use gml
And game maker can port all the drag and drop code that you have made until now into gml so you don't have to worry about it

So take my advice and switch to gml . It will benefit you . But of course. Its your decision


About the object
You only need one save object that saves everything .so all the save code has go be inside the same object.

Then you can call the save object from any room and in any moment when you want to save.
With the function instance_create_layer





About the image. Since I don't use drag n drop am just guessing that in the target you need to put the variable that you want to assign the saved variable . In this case it should be global.world
 
Last edited:
Top