Add MUX-style @chzone.
This commit is contained in:
parent
1a3942edac
commit
8ebea8c22e
3 changed files with 60 additions and 0 deletions
|
|
@ -76,6 +76,7 @@ GLOBAL_CMD_TABLE.add_command("@ccreate", commands.comsys.cmd_ccreate,
|
||||||
GLOBAL_CMD_TABLE.add_command("@cdestroy", commands.comsys.cmd_cdestroy,
|
GLOBAL_CMD_TABLE.add_command("@cdestroy", commands.comsys.cmd_cdestroy,
|
||||||
priv_tuple=("objects.delete_commchannel")),
|
priv_tuple=("objects.delete_commchannel")),
|
||||||
GLOBAL_CMD_TABLE.add_command("@chown", commands.objmanip.cmd_chown),
|
GLOBAL_CMD_TABLE.add_command("@chown", commands.objmanip.cmd_chown),
|
||||||
|
GLOBAL_CMD_TABLE.add_command("@chzone", commands.objmanip.cmd_chzone),
|
||||||
GLOBAL_CMD_TABLE.add_command("@cemit", commands.comsys.cmd_cemit),
|
GLOBAL_CMD_TABLE.add_command("@cemit", commands.comsys.cmd_cemit),
|
||||||
GLOBAL_CMD_TABLE.add_command("@clist", commands.comsys.cmd_clist),
|
GLOBAL_CMD_TABLE.add_command("@clist", commands.comsys.cmd_clist),
|
||||||
GLOBAL_CMD_TABLE.add_command("@create", commands.objmanip.cmd_create,
|
GLOBAL_CMD_TABLE.add_command("@create", commands.objmanip.cmd_create,
|
||||||
|
|
|
||||||
|
|
@ -422,6 +422,58 @@ def cmd_chown(command):
|
||||||
session.msg("Who should be the new owner of the object?")
|
session.msg("Who should be the new owner of the object?")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def cmd_chzone(command):
|
||||||
|
"""
|
||||||
|
Changes an object's zone. The specified zone may be of any object type, but
|
||||||
|
will typically be a THING.
|
||||||
|
|
||||||
|
Forms:
|
||||||
|
@chzone <Object>=<NewZone>
|
||||||
|
"""
|
||||||
|
session = command.session
|
||||||
|
pobject = session.get_pobject()
|
||||||
|
|
||||||
|
if not command.command_argument:
|
||||||
|
session.msg("Change the zone of what?")
|
||||||
|
return
|
||||||
|
|
||||||
|
eq_args = command.command_argument.split('=', 1)
|
||||||
|
target_name = eq_args[0]
|
||||||
|
zone_name = eq_args[1]
|
||||||
|
|
||||||
|
if len(target_name) == 0:
|
||||||
|
session.msg("Change the zone of what?")
|
||||||
|
return
|
||||||
|
|
||||||
|
if len(eq_args) > 1:
|
||||||
|
target_obj = Object.objects.standard_plr_objsearch(session, target_name)
|
||||||
|
# Use standard_plr_objsearch to handle duplicate/nonexistant results.
|
||||||
|
if not target_obj:
|
||||||
|
return
|
||||||
|
|
||||||
|
if not pobject.controls_other(target_obj):
|
||||||
|
session.msg(defines_global.NOCONTROL_MSG)
|
||||||
|
return
|
||||||
|
|
||||||
|
# Allow the clearing of a zone
|
||||||
|
if zone_name.lower() == "none":
|
||||||
|
target_obj.set_zone(None)
|
||||||
|
session.msg("%s is no longer zoned." % (target_obj))
|
||||||
|
return
|
||||||
|
|
||||||
|
zone_obj = Object.objects.standard_plr_objsearch(session, zone_name)
|
||||||
|
# Use standard_plr_objsearch to handle duplicate/nonexistant results.
|
||||||
|
if not zone_obj:
|
||||||
|
return
|
||||||
|
|
||||||
|
target_obj.set_zone(zone_obj)
|
||||||
|
session.msg("%s is now in zone %s." % (target_obj, zone_obj))
|
||||||
|
|
||||||
|
else:
|
||||||
|
# We haven't provided a target zone.
|
||||||
|
session.msg("What should the object's zone be set to?")
|
||||||
|
return
|
||||||
|
|
||||||
def cmd_link(command):
|
def cmd_link(command):
|
||||||
"""
|
"""
|
||||||
Sets an object's home or an exit's destination.
|
Sets an object's home or an exit's destination.
|
||||||
|
|
|
||||||
|
|
@ -753,6 +753,13 @@ class Object(models.Model):
|
||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def set_zone(self, new_zone):
|
||||||
|
"""
|
||||||
|
Sets an object's zone.
|
||||||
|
"""
|
||||||
|
self.zone = new_zone
|
||||||
|
self.save()
|
||||||
|
|
||||||
def move_to(self, target, quiet=False, force_look=True):
|
def move_to(self, target, quiet=False, force_look=True):
|
||||||
"""
|
"""
|
||||||
Moves the object to a new location.
|
Moves the object to a new location.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue