nakedmudv3.6/
nakedmudv3.6/lib/
nakedmudv3.6/lib/help/A/
nakedmudv3.6/lib/help/B/
nakedmudv3.6/lib/help/C/
nakedmudv3.6/lib/help/D/
nakedmudv3.6/lib/help/G/
nakedmudv3.6/lib/help/H/
nakedmudv3.6/lib/help/J/
nakedmudv3.6/lib/help/L/
nakedmudv3.6/lib/help/M/
nakedmudv3.6/lib/help/O/
nakedmudv3.6/lib/help/P/
nakedmudv3.6/lib/help/R/
nakedmudv3.6/lib/help/S/
nakedmudv3.6/lib/help/W/
nakedmudv3.6/lib/logs/
nakedmudv3.6/lib/misc/
nakedmudv3.6/lib/players/
nakedmudv3.6/lib/txt/
nakedmudv3.6/lib/world/
nakedmudv3.6/lib/world/examples/
nakedmudv3.6/lib/world/examples/mproto/
nakedmudv3.6/lib/world/examples/oproto/
nakedmudv3.6/lib/world/examples/reset/
nakedmudv3.6/lib/world/examples/rproto/
nakedmudv3.6/lib/world/examples/trigger/
nakedmudv3.6/lib/world/limbo/
nakedmudv3.6/lib/world/limbo/room/
nakedmudv3.6/lib/world/limbo/rproto/
nakedmudv3.6/src/alias/
nakedmudv3.6/src/dyn_vars/
nakedmudv3.6/src/editor/
nakedmudv3.6/src/example_module/
nakedmudv3.6/src/help2/
nakedmudv3.6/src/set_val/
nakedmudv3.6/src/socials/
nakedmudv3.6/src/time/
################################################################################
#
# cmd_misc.c
#
# a collection of miscellaneous commands that come with NakedMud(tm)
#
################################################################################
from mud import *
from hooks import *
from mudsys import add_cmd, add_cmd_check
import event, mudsys


def cmd_stop(ch, cmd, arg):
    '''If you are currently performing an action (for example, a delayed
       command), make an attempt to stop performing that action.'''
    if not ch.isActing():
        ch.send("But you're not currently performing an action!\r\n")
    else:
        ch.interrupt()

def cmd_clear(ch, cmd, arg):
    '''This command will clear your display screen.'''
    ch.send_raw("\033[H\033[J")

def event_delayed_cmd(ch, filler, cmd):
    '''used to perform delayed commands'''
    ch.act(cmd, True)

def cmd_delay(ch, cmd, arg):
    '''Usage: delay <seconds> <command>

       Allows the user to prepare a command to be executed in the future. For
       example:

       > delay 2 say hello, world!

       Will make you say \'hello, world!\' two seconds after entering the
       delayed command.'''
    try:
        secs, to_delay = parse_args(ch, True, cmd, arg, "double string")
    except: return

    if secs < 1:
        ch.send("You can only delay commands for positive amounts of time.")
    else:
        ch.send("You delay '%s' for %.2f seconds" % (to_delay, secs))
        event.start_event(ch, secs, event_delayed_cmd, None, to_delay)

def cmd_motd(ch, cmd, arg):
    '''This command will display to you the mud\'s message of the day.'''
    ch.page(get_motd())

def cmd_save(ch, cmd, arg):
    '''Attempt to save your character and all recent changes made to it, to
       disk. This automatically happens when logging out.'''
    mudsys.do_save(ch)
    ch.send("Saved.")

def cmd_quit(ch, cmd, arg):
    '''Attempts to save and log out of the game.'''
    log_string(ch.name + " has left the game.")
    mudsys.do_save(ch)
    mudsys.do_quit(ch)



################################################################################
# add our commands
################################################################################
add_cmd("stop",  None, cmd_stop,  "player", False)
add_cmd("clear", None, cmd_clear, "player", False)
add_cmd("delay", None, cmd_delay, "player", False)
add_cmd("motd",  None, cmd_motd,  "player", False)
add_cmd("save",  None, cmd_save,  "player", False)
add_cmd("quit",  None, cmd_quit,  "player", True)

chk_can_save = lambda ch, cmd: ch.is_pc
add_cmd_check("save", chk_can_save)
add_cmd_check("quit", chk_can_save)