def run_program(self, location, command, args): # The one and only special case needed for this, hopefully. if command == "save": # Get the log and trim the save command out! gameio.clear_input_log(1) input_log = gameio.get_input_log() if saveload.save_game(game.now_playing, input_log): gameio.write("Game saved successfully.\n") else: gameio.error("Game could not be saved.\n") return True else: return Computer.run_program(self, location, command, args)
def load_game(name): # Is there actually a game there? if not save_fs.path_is_dir(name): return False # Firstly, we need to actually load the stuff into memory game.now_playing = Save(save_info={}, history=[], name=name) game.now_playing.load(close=True, info_file=save_fs.file_open(computers.path_push(name, "saveinfo.txt"), 'r'), history_file=save_fs.file_open(computers.path_push(name, "history.txt"), 'r')) # Then we need to make a new game... start = computers.FirstComputer() # ...start logging... gameio.set_input_logging(True) # ...then set the replay up... gameio.set_replay(game.now_playing.history.copy()) # ...and start playing! start.shell() # Before we exit, make sure there is no replay! gameio.clear_replay() # Also stop logging, and clear it! gameio.set_input_logging(False) gameio.clear_input_log() return True