Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+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.