W
Wild_West
Guest
I'm finally at the last major leg of my game, I just need to make sure that the player can close the game and reload their saved data.
I did this easily in practice of course just to see the mechanic working, but when I moved back into my real game to implement it, I ran into the issue of , I have a global variable to check for erasing saved data, and loading saved data.
global.has_saved_file;
which is initialized to false of course.
So as you can well imagine this creates a problem whenever the game is restarted since all the rooms have to start again and the has_saved_file variable is re initialized, setting it back to false any time the game starts up again.
So this is my script for all the necessary checks before saving and loading, my question is is there a way I can still use the checks I need before I save but without global.has_saved_file ?
I did this easily in practice of course just to see the mechanic working, but when I moved back into my real game to implement it, I ran into the issue of , I have a global variable to check for erasing saved data, and loading saved data.
global.has_saved_file;
which is initialized to false of course.
So as you can well imagine this creates a problem whenever the game is restarted since all the rooms have to start again and the has_saved_file variable is re initialized, setting it back to false any time the game starts up again.
So this is my script for all the necessary checks before saving and loading, my question is is there a way I can still use the checks I need before I save but without global.has_saved_file ?
Code:
///menu_script()
//works with menu object only
switch(menu_position)
{
case 0 : {
//Start a new game
if( global.has_saved_file == false)
{room_goto(map_select_room); exit;}
//Ask if player will overwrite if there's already a saved file
if( global.has_saved_file == true)
{ new_game_check = show_question("This will erase any saved progress, are you sure ?"); }
//Choose not to overwrite save
if(new_game_check == false){ exit; }else
//Overwrite saved file
if(new_game_check == true) and ( global.has_saved_file == true )
{
show_message("Starting New Game");
//empty the collected treasures values
for(empty = 0; empty < array_length_1d(global.collection); empty ++)
{ global.collection[empty] = ""; }
//reset all cleared region stages
//empty columns
for(emptyColumn = 0;
emptyColumn < array_height_2d(global.region_cleared);
emptyColumn ++){
//empty rows
for(emptyRow = 0;
emptyRow < array_length_2d(global.region_cleared,emptyColumn);
emptyRow ++){global.region_cleared[emptyColumn, emptyRow] = false;}
}
global.has_saved_file = false;
game_restart();
}
break; }
//--------------------------------------------------------------------------------------------------------------------------------------
case 1 : {
load_check = show_question("Load save file ?");
if(load_check == false){ exit; }else
if(load_check == true) and (global.has_saved_file == false){ show_message("No Data found.."); }
if(load_check == true) and (global.has_saved_file == true)
{
ini_read_real("Player_info.ini", "West's_Stats", 0);
west_stats.fortune = ini_read_real("West's_Stats", "Fortune", west_stats.fortune );
west_stats.max_hp = ini_read_real("West's_Stats", "Hp", west_stats.max_hp );
west_stats.max_atk = ini_read_real("West's_Stats", "Atk", west_stats.max_atk );
west_stats.max_grd = ini_read_real("West's_Stats", "Grd", west_stats.max_grd );
west_stats.max_stock = ini_read_real("West's_Stats", "Stock", west_stats.max_stock);
west_stats.max_lan = ini_read_real("West's_Stats", "LAN", west_stats.max_lan );
west_stats.max_magic = ini_read_real("West's_Stats", "Magic", west_stats.max_magic);
ini_close();
show_message("Game Load Successful");
room_goto(map_select_room);
}
break; }
//--------------------------------------------------------------------------------------------------------------------------------------
case 2 : {
exit_check = show_question("This will turn the game off,
erasing any unsaved progress,
are you sure ?");
if(exit_check == false){ exit; }else
if(exit_check == true){ game_end(); }
break; }
//---------------------------------------------------------------------------------------------------------------------------------------
default : break;
}