def main(): try: opts, args = getopt.getopt(sys.argv[1:], "hl:w:", ["help", "load=", "world="]) except getopt.GetoptError: # print help information and exit: usage() app.quit() worldsource = None worldobj = None for option, argument in opts: if option in ("-h", "--help"): usage() app.quit() elif option in ("-w", "--world"): try: worldobj = world.load(load_world(argument)) except error.VersionError, e: io.errormsg("This world file requires a newer version (%s) of this game." % e.required) app.quit() elif option in ("-l", "--load"): try: worldobj = game.load(argument) except error.VersionError, e: io.errormsg("This save file was made using a different version (%s) of this game." % e.required) app.quit()
usage() app.quit() elif option in ("-w", "--world"): try: worldobj = world.load(load_world(argument)) except error.VersionError, e: io.errormsg("This world file requires a newer version (%s) of this game." % e.required) app.quit() elif option in ("-l", "--load"): try: worldobj = game.load(argument) except error.VersionError, e: io.errormsg("This save file was made using a different version (%s) of this game." % e.required) app.quit() except error.FileFormatError, e: io.errormsg(e.message) app.quit() if not worldobj: if app.config["main.last_game_save"]: game.output("--- Resuming your previous game. ---") worldobj = game.load(app.config["main.last_game_save"]) else: # Temporarily default to ocean. In the future, there will be a chooser in the system world. worldobj = world.load(load_world("ocean")) init(worldobj) if __name__ == "__main__": main()