Changed so object.move_to() traverses exits by default - i.e. you will no longer end up INSIDE the exit object if you move_to the exit, but instead you will go to the exits destination. This should be the most common use. The use_destination keyword to object.move_to can be used to change this behaviour. Also @teleport (which uses move_to()) has gotten a new flag to allow for teleporting into exits if so specifically desired. Resolves issue 224.
This commit is contained in:
parent
464aa8ca9e
commit
bcf214ee0d
2 changed files with 11 additions and 9 deletions
|
|
@ -1831,11 +1831,12 @@ class CmdTeleport(MuxCommand):
|
||||||
@tel/switch [<object> =] <location>
|
@tel/switch [<object> =] <location>
|
||||||
|
|
||||||
Switches:
|
Switches:
|
||||||
quiet - don't inform the source and target
|
quiet - don't echo leave/arrive messages to the source/target
|
||||||
locations about the move.
|
locations for the move.
|
||||||
|
intoexit - if target is an exit, teleport INTO
|
||||||
|
the exit object instead of to its destination
|
||||||
|
|
||||||
Teleports an object somewhere. If no object is
|
Teleports an object or yourself somewhere.
|
||||||
given we are teleporting ourselves.
|
|
||||||
"""
|
"""
|
||||||
key = "@tel"
|
key = "@tel"
|
||||||
aliases = "@teleport"
|
aliases = "@teleport"
|
||||||
|
|
@ -1874,8 +1875,11 @@ class CmdTeleport(MuxCommand):
|
||||||
if obj_to_teleport == destination:
|
if obj_to_teleport == destination:
|
||||||
caller.msg("You can't teleport an object inside of itself!")
|
caller.msg("You can't teleport an object inside of itself!")
|
||||||
return
|
return
|
||||||
|
use_destination = True
|
||||||
|
if "intoexit" in self.switches:
|
||||||
|
use_destination = False
|
||||||
# try the teleport
|
# try the teleport
|
||||||
if obj_to_teleport.move_to(destination, quiet=tel_quietly, emit_to_obj=caller):
|
if obj_to_teleport.move_to(destination, quiet=tel_quietly, emit_to_obj=caller, use_destination=use_destination):
|
||||||
if obj_to_teleport == caller:
|
if obj_to_teleport == caller:
|
||||||
caller.msg("Teleported to %s." % destination.key)
|
caller.msg("Teleported to %s." % destination.key)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ transparently through the decorating TypeClass.
|
||||||
import traceback
|
import traceback
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.contenttypes.models import ContentType
|
|
||||||
|
|
||||||
from src.utils.idmapper.models import SharedMemoryModel
|
from src.utils.idmapper.models import SharedMemoryModel
|
||||||
from src.typeclasses.models import Attribute, TypedObject, TypeNick, TypeNickHandler
|
from src.typeclasses.models import Attribute, TypedObject, TypeNick, TypeNickHandler
|
||||||
|
|
@ -25,12 +24,11 @@ from src.typeclasses.models import _get_cache, _set_cache, _del_cache
|
||||||
from src.typeclasses.typeclass import TypeClass
|
from src.typeclasses.typeclass import TypeClass
|
||||||
from src.objects.manager import ObjectManager
|
from src.objects.manager import ObjectManager
|
||||||
from src.players.models import PlayerDB
|
from src.players.models import PlayerDB
|
||||||
from src.server.models import ServerConfig
|
|
||||||
from src.commands.cmdsethandler import CmdSetHandler
|
from src.commands.cmdsethandler import CmdSetHandler
|
||||||
from src.commands import cmdhandler
|
from src.commands import cmdhandler
|
||||||
from src.scripts.scripthandler import ScriptHandler
|
from src.scripts.scripthandler import ScriptHandler
|
||||||
from src.utils import logger
|
from src.utils import logger
|
||||||
from src.utils.utils import make_iter, to_unicode, to_str, mod_import
|
from src.utils.utils import make_iter, to_unicode, mod_import
|
||||||
|
|
||||||
#__all__ = ("ObjAttribute", "Alias", "ObjectNick", "ObjectDB")
|
#__all__ = ("ObjAttribute", "Alias", "ObjectNick", "ObjectDB")
|
||||||
|
|
||||||
|
|
@ -640,7 +638,7 @@ class ObjectDB(TypedObject):
|
||||||
if not destination:
|
if not destination:
|
||||||
emit_to_obj.msg("The destination doesn't exist.")
|
emit_to_obj.msg("The destination doesn't exist.")
|
||||||
return
|
return
|
||||||
if destination.destination:
|
if destination.destination and use_destination:
|
||||||
# traverse exits
|
# traverse exits
|
||||||
destination = destination.destination
|
destination = destination.destination
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue