nakedmud-mod/
nakedmud-mod/html/tutorials/
nakedmud-mod/html/tutorials/building_extras/
nakedmud-mod/html/tutorials/c/
nakedmud-mod/html/tutorials/reference/
nakedmud-mod/html/tutorials/scripting/
nakedmud-mod/html/tutorials/scripting_extras/
nakedmud-mod/lib/
nakedmud-mod/lib/help/A/
nakedmud-mod/lib/help/B/
nakedmud-mod/lib/help/C/
nakedmud-mod/lib/help/D/
nakedmud-mod/lib/help/G/
nakedmud-mod/lib/help/H/
nakedmud-mod/lib/help/J/
nakedmud-mod/lib/help/L/
nakedmud-mod/lib/help/M/
nakedmud-mod/lib/help/O/
nakedmud-mod/lib/help/P/
nakedmud-mod/lib/help/R/
nakedmud-mod/lib/help/S/
nakedmud-mod/lib/help/W/
nakedmud-mod/lib/logs/
nakedmud-mod/lib/misc/
nakedmud-mod/lib/players/
nakedmud-mod/lib/pymodules/polc/
nakedmud-mod/lib/txt/
nakedmud-mod/lib/world/
nakedmud-mod/lib/world/zones/examples/
nakedmud-mod/lib/world/zones/examples/mproto/
nakedmud-mod/lib/world/zones/examples/oproto/
nakedmud-mod/lib/world/zones/examples/reset/
nakedmud-mod/lib/world/zones/examples/rproto/
nakedmud-mod/lib/world/zones/examples/trigger/
nakedmud-mod/lib/world/zones/limbo/
nakedmud-mod/lib/world/zones/limbo/room/
nakedmud-mod/lib/world/zones/limbo/rproto/
nakedmud-mod/src/alias/
nakedmud-mod/src/dyn_vars/
nakedmud-mod/src/editor/
nakedmud-mod/src/example_module/
nakedmud-mod/src/help2/
nakedmud-mod/src/set_val/
nakedmud-mod/src/socials/
nakedmud-mod/src/time/
'''
demo_prompt.py

Provides a short demo on how to write prompts and input handlers in Python, as
well as how the default prompt can be overwritten in Python.
'''
import mud, mudsys, socket

def new_prompt(sock):
    '''this prompt will be used to override the default NM prompt'''
    sock.send_raw("\r\nnew prompt> ")

def example_prompt(sock):
    '''used as an example of how to interact with the input handler stack'''
    sock.send_raw("\r\nexample prompt> ")

def example_handler(sock, arg):
    '''used as an example of how to interact with the input handler stack'''
    if arg.upper() == 'Q':
        sock.pop_ih()
    else:
        sock.send("You typed " + arg + ". Q to quit.")

def cmd_pyih(ch, cmd, arg):
    '''used as an example of how to interact with the input handler stack'''
    ch.socket.push_ih(example_handler, example_prompt)
    ch.send("New input handler set.")


# add the command that allows us to interact with the input handler stack
mudsys.add_cmd("pyih", None, cmd_pyih, "admin", False)

# override our default prompt with a new one
mudsys.show_prompt = new_prompt