def load(returnMode=None): global returnTo, loadName, saveFiles if returnMode is not None: returnTo = returnMode else: returnTo = town_mode saveFiles = sorted([fileName for fileName in os.listdir('save') if fileName[0] != '.']) try: saveFiles.insert(0, saveFiles.pop(saveFiles.index('quick.sav'))) except ValueError: pass universal.clear_world_view() universal.say_title('Load') universal.say('\n'.join(universal.numbered_list([sf for sf in saveFiles if sf[0] != '.']))) if len(saveFiles) < 10: universal.set_commands(['(#) Select a file to load:', '<==Back']) else: universal.set_commands(['(#) Select a file to load:_', '<==Back']) universal.set_command_interpreter(load_interpreter)
def save(previousModeIn): global saveFiles, previousMode previousMode = previousModeIn try: saveFiles = sorted([file for file in os.listdir('save') if file[0] != '.']) except OSError: os.mkdir('save') saveFiles = sorted([file for file in os.listdir('save') if file[0] != '.']) universal.clear_world_view() universal.say_title('Save') try: saveFiles.insert(0, saveFiles.pop(saveFiles.index('quick.sav'))) except ValueError: pass universal.say('\n'.join(universal.numbered_list(saveFiles))) if len(saveFiles) < 10: universal.set_commands(['Provide a save name:_', '(#) Select a save file.', '<==Back']) else: universal.set_commands([' '.join(['Provide a save name:_']), '(#) Select a save file:_', '<==Back']) universal.set_command_interpreter(save_interpreter)