Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def cmd_getaux(ch, cmd, arg):
- '''Allows an ADMIN to peek at a value stored in a given set of auxiliary data
- syntax: getaux <target> <item>'''
- arg = arg.lower()
- parts = arg.split(" ")
- if len(parts) != 2:
- ch.send("This command requires 2 arguments!")
- else:
- try:
- tgt, = mud.parse_args(ch, True, cmd, parts[0], "ch.world")
- except: return
- if not hasattr(tgt.aux('Stats'), parts[1]):
- ch.send("That value doesn't exist on the given object!")
- else:
- ch.send("%s: %s" % (parts[1], (getattr(tgt.aux('Stats'), parts[1]))))
- def cmd_setaux_test(ch, cmd, arg):
- '''Allows an ADMIN to set a value stored in a given set of auxiliary data
- syntax: setaux <target> <item> <value>'''
- arg = arg.lower()
- parts = arg.split(" ")
- if len(parts) != 3:
- ch.send("This command requires 3 arguments!")
- else:
- try:
- tgt, = mud.parse_args(ch, True, cmd, parts[0], "ch.world")
- except: return
- if not hasattr(tgt.aux('Stats'), parts[1]):
- ch.send("That item doesn't exist on the target.")
- else:
- # Try getting a type and casting.
- t = type(getattr(tgt.aux('Stats'), parts[1]))
- try:
- parts[2] = t(parts[2])
- except ValueError:
- ch.send("Cannot convert %r to proper type for %s." % (
- parts[2], parts[1]))
- return
- setattr(tgt.aux('Stats'), parts[1], parts[2])
- ch.send("Key '%s' set to %s" % (parts[1], parts[2]))
Add Comment
Please, Sign In to add comment