woods
Member
following along this short quick tutorial to save/load my game
according to awesome F1 help button, my default save directory is
%localappdata%\<Game Name> directory
the save button works.. as i can navigate to the folder and see the changes made to the ini file.
my problem is with the load button.. not sure if it is not reading the file or the player stats are being overwritten when the room is loaded..
obj_save_button
left_pressed event
obj_load_button
left_pressed event
if it has any bearing..
play room is not persistent
i have an instance of obj_player placed in the room thru the editor
a little assistance would be appreciated
INI Save/Load [GameMaker: Studio]
You’ve made a game and it’s going well, but you need to add a save feature so that the player can continue with their adventure – ini functions will do the trick. ini functions us…
gdpalace.wordpress.com
according to awesome F1 help button, my default save directory is
%localappdata%\<Game Name> directory
the save button works.. as i can navigate to the folder and see the changes made to the ini file.
my problem is with the load button.. not sure if it is not reading the file or the player stats are being overwritten when the room is loaded..
obj_save_button
left_pressed event
GML:
/// L click to save
ini_open(working_directory + 'savedata.ini');
ini_write_real('savegame', 'roomID', room); //saves room id with key roomID
ini_write_real('savegame', 'xPos', obj_player.x); //saves player X location
ini_write_real('savegame', 'yPos', obj_player.y); //saves player Y location
ini_write_real('savegame', 'my_level', obj_player.my_level);
ini_write_real('savegame', 'my_exp', obj_player.my_exp);
ini_write_real('savegame', 'my_target_exp', obj_player.my_target_exp);
ini_write_real('savegame', 'my_health', obj_player.my_health);
ini_write_real('savegame', 'my_max_health', obj_player.my_max_health);
ini_write_real('savegame', 'my_gold', obj_player.my_gold);
ini_write_string('savegame', 'state', obj_player.state);
ini_close();
obj_load_button
left_pressed event
GML:
/// L click to load
var roomID;
ini_open(working_directory + 'savedata.ini');
roomID = ini_read_real('savegame', 'roomID', 0);
obj_player.x = ini_read_real('savegame', 'xPos', 0);
obj_player.y = ini_read_real('savegame', 'yPos', 0);
obj_player.my_level = ini_read_real('savegame','my_level',1);
obj_player.my_exp = ini_read_real('savegame','my_exp',0);
obj_player.my_target_exp = ini_read_real('savegame','my_target_exp',0);
obj_player.my_health = ini_read_real('savegame','my_health',0);
obj_player.my_max_health = ini_read_real('savegame','my_max_health',0);
obj_player.my_gold = ini_read_real('savegame','my_gold',0);
obj_player.state = ini_read_string('savegame','state','idle');
ini_close();
room_goto(roomID);
play room is not persistent
i have an instance of obj_player placed in the room thru the editor
a little assistance would be appreciated
Last edited: