def change(key): if app.config.has_key(key): value = game.input("Change to: ") # Convert what the user input to the previous value type of the setting keytype = type(app.config[key]) value = keytype(eval(value)) app.config[key] = value game.output("You write %s under %s." % (value, key)) else: game.output("The paper has no field named %s." % key)
def read(): game.output("The paper says:") game.output("=== Config ===") for section in app.config.sections(): game.output("\n[%s]" % section) for key, value in app.config.items(section): game.output("%s.%s: %s" % (section, key, value))
def do_shell(self): game.output(self.messages["activate"](me=self.name)) game.output("Type \"done\" to exit.") cmd = None while cmd != "done": if cmd: try: print repr(eval(cmd)) except SyntaxError: try: exec cmd except: traceback.print_exc() except: traceback.print_exc() cmd = game.input(">>> ") game.output(self.messages["deactivate"](me=self.name))
def kick(): game.output(self.messages["kick"])
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()
def read(): game.output(self.get_description())
def talk(): game.output(self.messages["talk"](thing=self.name))
def kick(): game.output(self.messages["kick"](thing=self.name))
def eat(): game.output(self.messages["eat"])
def talk(): game.output("You talk to yourself.")