0

my game in gamemaker consists of various rooms which are levels and you go on progressing, so imagine im in level 7, and I leave the game, it obviously goes back to room 1, im using the coding language of gamemaker btw.Also the only thing I have to save is just the level im in, I dont want to save any coins or smth!

Does anyone know how to stop and save the game to later on go back to it?

Thank you so much in advance!

T14Seara
  • 37
  • 4
  • You're far more likely to get a good answer to this on https://gamedev.stackexchange.com/ – Basic Jun 17 '23 at 23:38

1 Answers1

0

There are multiple ways to handle a saving method.

For example, one is to create a file and store the level variable there, using file_text_open_write.

var file;
file = file_text_open_write(working_directory + "level.txt");
file_text_write_string(file, level_data);
file_text_close(file);

Then, let the program read the file when opening the game to get the level data from it. Using file_text_open_read

var file = file_text_open_read(working_directory + "hiscore.txt");
for (var i = 0; i < 10; ++i;)
{
    scr[i] = file_text_read_real(file);
    file_text_readln(file);
    scr_name[i] = file_text_read_string(file);
    file_text_readln(file);
}
file_text_close(file);

Source for more information: https://manual.yoyogames.com/GameMaker_Language/GML_Reference/File_Handling/Text_Files/file_text_open_write.htm
and https://manual.yoyogames.com/GameMaker_Language/GML_Reference/File_Handling/Text_Files/file_text_read_string.htm

Steven
  • 1,996
  • 3
  • 22
  • 33