Added the ability of obj.move_to to accept a None location with a keyword to_none. Also changed the @tel command to accept a /tonone switch for putting things' location to None. Resolves Issue 307.

This commit is contained in:
Griatch 2012-10-23 22:31:51 +02:00
parent fc4d7c92f9
commit ce036e07f3
3 changed files with 62 additions and 17 deletions

View file

@ -690,7 +690,7 @@ class ObjectDB(TypedObject):
self.msg_contents(message, exclude=exclude, from_obj=from_obj, data=data)
def move_to(self, destination, quiet=False,
emit_to_obj=None, use_destination=True):
emit_to_obj=None, use_destination=True, to_none=False):
"""
Moves this object to a new location.
@ -708,6 +708,8 @@ class ObjectDB(TypedObject):
use_destination (bool): Default is for objects to use the "destination" property
of destinations as the target to move to. Turning off this
keyword allows objects to move "inside" exit objects.
to_none - allow destination to be None. Note that no hooks are run when moving
to a None location. If you want to run hooks, run them manually.
Returns True/False depending on if there were problems with the move. This method
may also return various error messages to the emit_to_obj.
@ -723,6 +725,11 @@ class ObjectDB(TypedObject):
emit_to_obj = self
if not destination:
if to_none:
# immediately move to None. There can be no hooks called since
# there is no destination to call them with.
self.location = None
return True
emit_to_obj.msg(_("The destination doesn't exist."))
return
if destination.destination and use_destination:

View file

@ -86,7 +86,7 @@ class Object(TypeClass):
execute_cmd(raw_string)
msg(message, from_obj=None, data=None)
msg_contents(message, exclude=None, from_obj=None, data=None)
move_to(destination, quiet=False, emit_to_obj=None, use_destination=True)
move_to(destination, quiet=False, emit_to_obj=None, use_destination=True, to_none=False)
copy(new_key=None)
delete()
is_typeclass(typeclass, exact=False)
@ -231,7 +231,7 @@ class Object(TypeClass):
self.dbobj.msg_contents(message, exclude=exclude, from_obj=from_obj, data=data)
def move_to(self, destination, quiet=False,
emit_to_obj=None, use_destination=True):
emit_to_obj=None, use_destination=True, to_none=False):
"""
Moves this object to a new location. Note that if <destination> is an
exit object (i.e. it has "destination"!=None), the move_to will
@ -247,6 +247,8 @@ class Object(TypeClass):
use_destination (bool): Default is for objects to use the "destination" property
of destinations as the target to move to. Turning off this
keyword allows objects to move "inside" exit objects.
to_none - allow destination to be None. Note that no hooks are run when moving
to a None location. If you want to run hooks, run them manually.
Returns True/False depending on if there were problems with the move. This method
may also return various error messages to the emit_to_obj.