cmd_manip
index
/Users/hollis/Desktop/nakedmud/lib/pymodules/cmd_manip.py

################################################################################
#
# cmd_manip.py
#
# a set of commands that NakedMud(tm) comes with that allows characters to
# manipulate various things. These commands are mostly directed towards
# manipulating objects (e.g. get, put, drop, etc...) but can also affect other
# things like exits (e.g. open, close)
#
################################################################################

 
Modules
       
char
hooks
movement
mud
obj
mudsock
string
utils

 
Functions
       
add_cmd(...)
add_cmd(name, shorthand, cmd_func, user_group, interrupts_action)
 
Add a new command to the master command table. If a preferred shorthand
exists, e.g., 'n' for 'north', it can be specified. Otherwise, shorthand
should be None. Command functions take three arguments: a character
issuing the command, the command name, and a string argument supplied
to the command. Commands must be tied to a specific user group, and they
can optionally interupt character actions.
add_cmd_check(...)
add_cmd_check(name, check_func)
 
Add a new command check to a registered command. Check functions take
two arguments: the character issuing the command, and the command name.
If a check fails, it should return False and send the character a
message why.
chk_can_manip(ch, cmd)
cmd_close(ch, cmd, arg)
Usage: close <direction | door | container>
 
Attempts to close the specified door, direction, or container.
cmd_drop(ch, cmd, arg)
Usage: drop <item>
 
Attempts to move an object from your inventory to the ground.
cmd_get(ch, cmd, arg)
Usage: get [the] <item> [[from] <other item>]
 
Attempts to move an object from the room to your inventory. If an
addition argument is supplied, the command assumes it is a container and
instead tries to move an object from the container to your inventory.
cmd_give(ch, cmd, arg)
Usage: give <object> [to] <person>
 
Attempts to transfer an object from your inventory to the specified
person. You can give multiple objects at a time by using the all.
prefix. For example:
 
> give all.cookie george
 
Would give all of the cookies in your inventory to George. If you only
want to give him the raisin cookie, which also happens to be the third
cookie in your inventory, you can use a numeric prefix instead of
the all prefix. For example:
 
> give 3.cookie george
cmd_lock(ch, cmd, arg)
Usage: lock <direction | door | container>
 
Attempts to lock a specified door, direction, or container.
cmd_open(ch, cmd, arg)
Usage: open [the] <direction | door | container>
 
Attempts to open the speficied door, direction, or container.
cmd_put(ch, cmd, arg)
Usage: put [the] <item> [in the] <container>
 
Attempts to move an object from your inventory into a specified
container. The container must be in the room, in your inventory, or
worn.
cmd_remove(ch, cmd, arg)
Usage: remove <item | all>
 
Attempts to remove an item you have equipped. If you would like to
remove everything you are wearing, you may instead specify 'all'
instead of a specific item. If you would like to remove all of a certain
type of object (for instance, rings) you can use an all. prefix. For
example:
 
> remove all.ring
 
This command will remove everything you are wearing with the 'ring'
keyword. If you would instead like to remove, say, the second thing you
are wearing with the 'ring' keyword, you can supply a numeric prefix.
For example:
 
> remove 2.ring
cmd_unlock(ch, cmd, arg)
Usage: unlock <door | direction | container>
 
Attempts to unlock the specified door, direction, or container.
cmd_wear(ch, cmd, arg)
Usage: wear <item> [where]
 
Attempts to equip an item from your inventory. If you would like to
equip it to a non-default location, you can supply where on your body
you would like to wear it. For example, if you would like to equip a
torch, but in your offhand instead of your mainhand:
 
> wear torch offhand
 
If an item covers multiple locations on your body, you can specify where
all you would like to equip the item as a comma-separated list:
 
> wear gloves left hand, right hand
do_drop(ch, obj)
handles object dropping
do_get(ch, obj, cont)
transfers an item from the ground to the character
do_give(ch, recv, obj)
does the handling of the give command
do_put(ch, obj, cont)
handles the putting of objects
do_remove(ch, obj)
handles equipment removing
do_wear(ch, obj, where)
handles object wearing
erase_global(...)
erase_global(name)
 
Delete a value from the global variable table.
extract(...)
extract(thing)
 
Extracts an object, character, or room from the game.
format_string(...)
format_string(text, indent=True, width=80)
 
Format a block of text to be of the specified width, possibly indenting
paragraphs.
generic_find(...)
Deprecated. Use mud.parse_args instead.
get_global(...)
get_global(name)
 
Return a non-persistent global variable, or None.
get_greeting(...)
get_greeting()
 
returns the mud's connection greeting.
get_hour(...)
get_hour()
 
Return the current in-game hour of day.
get_motd(...)
get_motd()
 
Returns the mud's message of the day.
get_time(...)
get_time()
 
Return time of day (morning, afternoon, evening, night).
is_afternoon(...)
True or False if it is afternoon.
is_evening(...)
True or False if it is evening.
is_morning(...)
True or False if it is morning.
is_night(...)
True or False if it is night.
is_race(...)
is_race(name)
 
Returns True or False if the string is a valid race name.
ite(...)
ite(logic_statement, if_statement, else_statement=None)
 
A functional form of if/then/else.
keys_equal(...)
keys_equal(key1, key2)
 
Returns whether two world database keys are equal, relative to the
locale (if any) that the current script is running in.
list_races(...)
list_races(player_only=False)
 
Return a list of available races. If player_only is True, list only the
races that players have access to.
log_string(...)
log_string(mssg)
Send a message to the mud's log.
message(...)
message(ch, vict, obj, vobj, show_invis, range, mssg)
 
Send a message via the mud messaging system using $ expansions. Range
can be 'to_room', 'to_char', 'to_vict', or 'to_world'.
parse_args(...)
parse_args(ch, show_usage_errors, cmd, args, format)
 
equivalent to parse_args written in C. See parse.h for information.
set_global(...)
set_global(name, val)
 
Sets a non-persistent global variable. Val can be any type.
try_get_from(ch, cont, arg)
tries to get one item from inside another
try_manip_other_exit(room, ex, closed, locked)
used by open, close, lock, and unlock. When an exit is manipulated on one
side, it is the case that we'll want to do an identical manipulation on
the other side. That's what we do here. Note: Can only do close OR lock
with one call to this function. Cannot handle both at the same time!

 
Data
        cardinal_dirs = ['north', 'south', 'east', 'west']
cmd = 'unlock'
compass_dirs = ['north', 'south', 'east', 'west', 'northwest', 'northeast', 'southwest', 'southeast']