• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Game saving.

N

nickvm98

Guest
I'm searching for an understandable way to consistently save work in a file directory where the user can find it. I've considered just making a folder but the sandbox restricts this. I've tried bypassing the sandbox with extensions but it was too troublesome with my game. Now I have finally given up and just want a simple way a user can choose where to put the save file and perhaps load it onto a USB.
 
T

Taddio

Guest
ini_write is the simplest way, but it will be easy for the user to just open the file and change things. It saves, tho.
 
N

nickvm98

Guest
Code:
global.game_name=environment_get_variable("USERNAME");
global.game_inifile=get_save_filename(".ini",string(global.game_name)+"_save");
ini_open(global.game_inifile);
if global.game_inifile="" or global.game_inifile=" " {
    ini_write_real("device","display_w",display_get_width());
    ini_write_real("device","display_h",display_get_height());
    ini_write_string("device","display_ratio",string(global.display_ratio));
    ini_write_real("setting","window_w",global.window_w);
    ini_write_real("setting","window_h",global.window_h);
    ini_write_real("setting","screen_crop",global.crop);
    ini_write_real("setting","antiallias",global.allias);
    ini_write_string("setting","language","english");
    ini_write_string("input","keyboard1","1");
    ini_write_string("input","keyboard2","2");
    ini_write_string("input","gamepad1","1");
    ini_write_string("input","gamepad2","2");
}
ini_close();

I've quickly developed this for my settings.
-It asks for the location, every time.
-The file itself doesn't contain none of the things I've written to it.
-I cannot find it easily.

How do I fix this?
 
T

Taddio

Guest
File name should be a string.
Basically:
Code:
if (file_exists("options.ini")){
ini_open("options.ini");
 ini_write_real("display_w","display_h",display_get_height());
//Add things you want to save//
ini_close("options.ini");
}
You can also destroy the section you're going to write to, but that's the basic of it.
 
T

Taddio

Guest
Well, it does on my end. Have you checked in the gane directory if the file is at least created and what's in it?
 
N

nickvm98

Guest
Not in %localappdata% or %appdata%. My creative solution is just to make a gm1.4 program to proxy commands outside the sandbox but I dont wanna do that. Id rather just keep things simple for now.
 

chamaeleon

Member
Code:
global.game_name=environment_get_variable("USERNAME");
global.game_inifile=get_save_filename(".ini",string(global.game_name)+"_save");
ini_open(global.game_inifile);
if global.game_inifile="" or global.game_inifile=" " {
    ini_write_real("device","display_w",display_get_width());
    ini_write_real("device","display_h",display_get_height());
    ini_write_string("device","display_ratio",string(global.display_ratio));
    ini_write_real("setting","window_w",global.window_w);
    ini_write_real("setting","window_h",global.window_h);
    ini_write_real("setting","screen_crop",global.crop);
    ini_write_real("setting","antiallias",global.allias);
    ini_write_string("setting","language","english");
    ini_write_string("input","keyboard1","1");
    ini_write_string("input","keyboard2","2");
    ini_write_string("input","gamepad1","1");
    ini_write_string("input","gamepad2","2");
}
ini_close();

I've quickly developed this for my settings.
-It asks for the location, every time.
-The file itself doesn't contain none of the things I've written to it.
-I cannot find it easily.

How do I fix this?
You realize you only attempt to write your entries to the ini file if the filename is blank or a space, right?
 

Evanski

Raccoon Lord
Forum Staff
Moderator
I recommend you just use a .ini thats saved in the working directory or %appdata% gamers arent idiots, the people looking for will know how to find it there, hiding it somewhere else makes it harder for the player to do anything with it you want them to, if your doing it for game settings have the game save them to a ini file, have the player change them in-game, and have the game read the ini file to get the correct properties, if its a save file you can simply 64base encode it so its harder to make sense of out of game
 
Top