I made a script that modifies scene_gameover and adds two commands to it called "continue" and "end game", the script worked out the way I had hoped it would: whenever I died, I would just choose "continue" the game would automatically load my most recent save file.
Up until yesterday, I found a problem with my script. I started a new game and died (without saving) and saw that my continue was selectable... so I chose that command and found out it took me back to my old saved game that I was playing before. I needed to find a way to disable the continue when a new game is started and re-enable the command when a game is saved.
My (failed) solution was to try and make the scene_gameover start method check whether "@can_continue" is == true / false. depending on that variable, it would either enable / disable the command for continue... but I just can't get anything to work... I tried but no luck, I keep getting errors like uninitialized etc.
Does anyone know how I could check whether a variable is true or not from different classes? If not, is there any alternate way to solve this problem? any help is greatly appreciated
EDIT: Here is the script
EDIT: Oh, the script was lacking an "end".. sorry (fixed)
Up until yesterday, I found a problem with my script. I started a new game and died (without saving) and saw that my continue was selectable... so I chose that command and found out it took me back to my old saved game that I was playing before. I needed to find a way to disable the continue when a new game is started and re-enable the command when a game is saved.
My (failed) solution was to try and make the scene_gameover start method check whether "@can_continue" is == true / false. depending on that variable, it would either enable / disable the command for continue... but I just can't get anything to work... I tried but no luck, I keep getting errors like uninitialized etc.
Does anyone know how I could check whether a variable is true or not from different classes? If not, is there any alternate way to solve this problem? any help is greatly appreciated
EDIT: Here is the script
EDIT: Oh, the script was lacking an "end".. sorry (fixed)
#==============================================================================
# ** Window_TitleCommand
#------------------------------------------------------------------------------
# This window is for selecting New Game/Continue on the title screen.
#==============================================================================
class Window_GameOver < Window_Command
def initialize
super(0, 0)
update_placement
select_symbol🙂continue) if save_file_exists
self.openness = 0
open
end
def update_placement
self.x = (Graphics.width - width) / 2
self.y = (Graphics.height * 1.6 - height) / 2
end
def window_width
return 160
end
def make_command_list
add_command("Continue", :continue, save_file_exists)
add_command("End Game", :end_game)
end
def save_file_exists
DataManager.save_file_exists?
end
end
#==============================================================================
# ** Scene_Gameover
#------------------------------------------------------------------------------
# This class performs game over screen processing.
#==============================================================================
class Scene_Gameover < Scene_Base
def start
super
play_gameover_music
fadeout_frozen_graphics
create_background
create_command_window
end
def create_command_window
@command_window = Window_GameOver.new
@command_window.set_handler🙂continue, method🙂command_continue))
@command_window.set_handler🙂end_game, method🙂command_end_game))
end
def command_continue
@index = DataManager.latest_savefile_index
DataManager.load_game(@index)
on_load_success
end
def on_load_success
Sound.play_load
fadeout_all
$game_system.on_after_load
SceneManager.goto(Scene_Map)
end
def command_end_game
SceneManager.goto(Scene_Title)
end
def close_command_window
@command_window.close
update until @command_window.close?
end
def update
super
end
def play_gameover_music
RPG::BGM.stop
RPG::BGS.stop
Audio.bgm_play('Audio/BGM/' + "Dungeon1", 100, 100)
end
def create_background
@sprite = Sprite.new
@sprite.bitmap = Cache.system("GameOver")
end
end
# ** Window_TitleCommand
#------------------------------------------------------------------------------
# This window is for selecting New Game/Continue on the title screen.
#==============================================================================
class Window_GameOver < Window_Command
def initialize
super(0, 0)
update_placement
select_symbol🙂continue) if save_file_exists
self.openness = 0
open
end
def update_placement
self.x = (Graphics.width - width) / 2
self.y = (Graphics.height * 1.6 - height) / 2
end
def window_width
return 160
end
def make_command_list
add_command("Continue", :continue, save_file_exists)
add_command("End Game", :end_game)
end
def save_file_exists
DataManager.save_file_exists?
end
end
#==============================================================================
# ** Scene_Gameover
#------------------------------------------------------------------------------
# This class performs game over screen processing.
#==============================================================================
class Scene_Gameover < Scene_Base
def start
super
play_gameover_music
fadeout_frozen_graphics
create_background
create_command_window
end
def create_command_window
@command_window = Window_GameOver.new
@command_window.set_handler🙂continue, method🙂command_continue))
@command_window.set_handler🙂end_game, method🙂command_end_game))
end
def command_continue
@index = DataManager.latest_savefile_index
DataManager.load_game(@index)
on_load_success
end
def on_load_success
Sound.play_load
fadeout_all
$game_system.on_after_load
SceneManager.goto(Scene_Map)
end
def command_end_game
SceneManager.goto(Scene_Title)
end
def close_command_window
@command_window.close
update until @command_window.close?
end
def update
super
end
def play_gameover_music
RPG::BGM.stop
RPG::BGS.stop
Audio.bgm_play('Audio/BGM/' + "Dungeon1", 100, 100)
end
def create_background
@sprite = Sprite.new
@sprite.bitmap = Cache.system("GameOver")
end
end