Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Yup, exactly. This is the one that's showing up:

Game Room

which should only appear if a saved file was found. I've tried doing the "Start New Game" option which finds and deletes the current save file, but it doesn't really do anything and I still see this screen. Also, the 50-char randomly generated string for the save file variable was a pretty new addition, but after uploading that and running for the first time, same problem. There shouldn't be a duplicate of it on itch's server I believe.

since your saving and loading mechanism work, I guess you can try to read that phantom file first, and if the read operation is successful then display the dialogue xD

(Use try-catch to try and read that file first)

Gotcha, so I tried loading the game (which reads from the phantom file) as soon as it enters the room, but then the game just freezes. Getting this error:

However, I think I know what's going on! I was doing some research earlier tonight and starting looking into the actual errors themselves. 403 is a permissions error, which I think means my game isn't able to access the save file on the remote server. So what I believe is happening (just an educated guess) is that somehow, the game thinks a save file exists, but when it goes to grab it from itch's remote server, it doesn't actually exist so is producing the errors above. I checked GMS2's documentation for "file_exists" and found something really interesting: https://manual.yoyogames.com/GameMaker_Language/GML_Reference/File_Handling/File...

They specifically say:

"Note that the function can only be used to check local files, but not any files stored on a remote server."

So I'm assuming that's the error, since the way I'm checking save files is using that function. However, I do know that you're also using that same function in your code and it's working, so I'm really not sure what's going on 😅.

(2 edits)

somehow, the game thinks a save file exists, but when it goes to grab it from itch’s remote server, it doesn’t actually exist so is producing the errors above.

I actually got the same error and came to the same conclusion as you in one of my games.

My solution to that was to use ini_open(filename) this function will create a new ini file if one doesn’t exist

then I check if ini_section_exists(“data”), “data” can be the section name you will write. If this section doesn’t exist then there are no save file (cus its a new ini file being created).

This is roundabout way but it should work!

NOTE: I’m not telling you to write your save data into an ini file, you just need to create an ini file as a way to check if a save file exists

Weirdly enough that was the only game I had that error with file_exists, my other games file_exists work just fine >.<

Ok that makes sense, thank you! So I'm running into a bit of an error trying to do this, as it seems my "options.ini" is in the "html5game" directory. Here's some pics of testing on localhost:

So my game is trying to grab "options.ini" from inside the html5game, but I know that it's not actually in that directory, but rather on the same level based on the image below from one of my previous zip exports.


This is just some test code I have in a "Key Press - P" in my gameManager object.

ini_open("options.ini");
if ini_section_exists("DisplayName") {
show_debug_message("section exists");
}
ini_close();

However, I have a feeling this is different from what you were suggesting. Is this what you meant by reading the filename - the "options.ini"? Or did you mean I should "ini_open" my save file, the "dive-bitsloth-50char" file? Sorry, first time working with ini files so I'm not too familiar with how this all works haha. I'm a little confused how checking a section in the ini file relates to whether a save file exists. Would this be a custom section I'm creating myself?

(4 edits)

I only get a similar error when I play my game in Incognito mode. Are you testing your game in Incognito?

add me on discord if you want to keep in contact 🦁🔥#8269

This is a large part of my load code:

ini_open("settings.ini");

if (!ini_section_exists("data")){
    ini_write_real("data", "init game", 1);
    ini_write_real("data", "version", version);
    ini_write_real("setting", "sound", 1);
    global.new_game = true;
    loadbar.init = true;
}else{
    if (ini_read_real("data", "version", 0) != version){
        show_message("WARNING: Save data is of previous version. Unfortunately, data must be reset.");
        clear_user_data();
	ini_close();
        room_restart();
	exit;
    }
    global.new_game = false;
    loadbar.rm_next = rmMainMenu;  
    load_game(); //load the actual save file here
}
(+1)

This worked, thank you so much!! I used your code as a starting point and incorporated it into my existing code:

if room = rm_start {
    if keyboard_check_pressed(ord("D")) {
        ini_open("../options.ini");
        // debug purposes: delete section if exists
        if ini_section_exists(global.section) {
            ini_section_delete(global.section);
            show_debug_message("data section deleted");
        }
        ini_close();
    }
     
    if keyboard_check_pressed(ord("Z")) {
        global.sfx = "blip"; // sfx global var used in switch case
    
        // ini check code
        ini_open("../options.ini");
        show_debug_message("ini successfully opened"); // console message
        if ini_section_exists(global.section) {
            if (ini_read_real(global.section, global.key, -1) = global.val) {
                global.firstTime = false;    // used in other code to display/hide screen
                show_debug_message("section AND key exist - RETURNING PLAYER");
            } else {
                global.firstTime = true;
                ini_write_real(global.section, global.key, global.val);
                show_debug_message("section exists BUT key DOESN'T (I think?)- NEW GAME");
            }
        } else {
            global.firstTime = true;
            ini_write_real(global.section, global.key, global.val);
            show_debug_message("section DOESN'T exist - NEW PLAYER");
        }
        ini_close();
        room_goto(rm_game);
    }
     
    if keyboard_check_pressed(vk_escape) {
        game_end();
    }
}

Some really weird things were happening, like the INI section would never truly delete. I kept pressing "D" in-game and would keep getting that message over and over again, which seems impossible since it only runs if the section exists. So every time I reuploaded the zip for my game, I'd have to change the global.section string name to something different, because the previous section would still exist even after I'd deleted it.

There was also an issue with starting a new game, where I had to delete both the key and the section and do a check for that. Not completely sure why I had to do some of the things I had to do, but I ended up with three different states - returning players, players who started a new game in-game, and completely new first-time players.

Quick question - wondering if you've ever run into this: do you have to randomly generate save file names? Mine is just hardcoded into my game:

save_file = "dive-bitsloth-fIt0QNLgfAlboxByK9zdWOKRXRvzbMWeafIm4Q6LLlV9vykE5T.save";

If that save file is hosted on itch's servers, wouldn't all users be pulling from the same one? The thing is though, I tested it on two laptops (using the secret url, still unpublished) and got two separate, correct save instances for each user, so it does seem to work, though I'm confused as to how! Let me know if you've got any experience with this :)

Thanks for all the help! Your advice and coding insights have been really valuable. I'm going to try exporting to Mac and Windows too so I may bother you about that as well ;). I recently found out that you need a (paid) apple developer account for mac exports, so that's unfortunate.

Will add you on discord when I get a chance!

(1 edit)

Quick question - wondering if you’ve ever run into this: do you have to randomly generate save file names? Mine is just hardcoded into my game

I never had to change my game’s save file names, I did run into trouble when I used a super generic save file name across my games and my games overwrote each other’s save files xD

If that save file is hosted on itch’s servers, wouldn’t all users be pulling from the same one?

Save files are not saved on ItchIO servers, they are placed in your browser’s localStorage. However because ItchIO counts as only one domain, all ItchIO games will share the same localStorage container. This means other games you play on Itch will also have direct access to your game’s save files.