Beispiel #1
0
def run_system_world():
	# Switch to the system world temporarily, retaining the old world state.
	game.currentworld = game.world
	game.world = world.load(load_world("system"))
	
	io.output("--- Entering System World ---")
	game.world.protagonist.globalcommands = game.currentworld.protagonist.globalcommands
	game.world.protagonist.commands["look"]()
	
	while True:
		print
		try:
			cmd = io.input("> ")
		except (KeyboardInterrupt, EOFError):
			game.world = game.currentworld
			save_and_quit()
			
		if cmd in ("done", "leave"):
			break
		game.world.protagonist.do_command(cmd)
	
	io.output("--- Leaving System World ---")
	game.world = game.currentworld
	game.currentworld = None
	game.world.protagonist.commands["look"]()
Beispiel #2
0
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()
Beispiel #3
0
			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()