Example #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"]()
Example #2
0
def save_and_quit():
	io.output("Bye.")
	
	# Return from the system world if we are in it
	if hasattr(game, "currentworld") and game.currentworld:
		game.world = game.currentworld
	
	if game.playing and app.config["main.save_on_exit"]:
		filename = game.save()
		io.output("--- Your game has been saved. ---")
		app.config["main.last_game_save"] = filename
	app.quit()
Example #3
0
		def save():
			game.save()
			io.output("Your game has been saved.")
Example #4
0
import string
import sys

# We want to use libs from the parent directory
sys.path.append("..")
sys.path.append(".")

import io_basic as io
from library import npc

mybot = npc.MarkovNPC("MyBot", "MarkovGen Dummy Bot")
mybot.vars["markov"] = dict()

io.output("""\
Markov Chain Generator
Use this tool to create brains for Markov chain NPCs. Please enter sentences to "teach" the bot; do note that due to the nature of Markov bots, these words will be mashed up and rearranged once enough sentences have been entered. Shoot for at least 15-25 sentences. 

At any time, a blank line or "!say ___" will simulate speaking to the bot. Type "!quit" to exit (and output the Markov chains).
""", fast=True)

while 1:
	sentence = io.input("Add a sentence: ")
	
	if sentence == "!quit":
		break
	if sentence[0:4] == "!say" or sentence == "":
		if mybot.vars["markov"]:
			if sentence != "":
				said = sentence[4:]
			else:
				said = ""
			io.output("The bot says: " + mybot.walk_chain(said=said))