Repository: evennia/evennia

Issue:
Feature Request: Add a switch to @tel to allow teleporting to an object's location
#### Description of requested feature:
Evennia's `@tel` command defaults to teleporting your character into another object, for instance:
`@tel Griatch`
would teleport my puppeted character into Griatch's inventory.
This is a little odd, but expected, since `@tel` is meant to be used to teleport objects into other objects, e.g. `@tel an apple = chainsol` will teleport the apple to your inventory. For teleporting to other characters, this gets a little odd.

#### Reasons for adding feature:
Most people would expect `@tel chainsol` to teleport their character to the location. For a room or a container, Evennia's current behaviour makes sense. However, for teleporting to another character, it's a little odd - you end up part of their "inventory".

This is because Evennia treats objects differently than most systems - characters don't actually have an inventory, they have "contents". However, usually if you're teleporting to a character you expect to be in their location, not their inventory.

#### Expected result of feature/ideas on how to implement
One easy way to solve this is to add a switch to `@tel`, something like `@tel/loc` that teleports to the target's location.



Discussion:
Just to clarify: This feature request is for adding `@tel/loc` functionality. It is also important that the command gives a clear error and cancels if the target object has a location of `None`. 

Resolving patch:
diff --git a/evennia/commands/default/building.py b/evennia/commands/default/building.py
--- a/evennia/commands/default/building.py
+++ b/evennia/commands/default/building.py
@@ -2324,6 +2324,7 @@ class CmdTeleport(COMMAND_DEFAULT_CLASS):
                Note that the only way to retrieve
                an object from a None location is by direct #dbref
                reference. A puppeted object cannot be moved to None.
+      loc - teleport object to the target's location instead of its contents
 
     Teleports an object somewhere. If no object is given, you yourself
     is teleported to the target location.     """
@@ -2343,6 +2344,7 @@ def func(self):
         # setting switches
         tel_quietly = "quiet" in switches
         to_none = "tonone" in switches
+        to_loc = "loc" in switches
 
         if to_none:
             # teleporting to None
@@ -2368,7 +2370,7 @@ def func(self):
 
         # not teleporting to None location
         if not args and not to_none:
-            caller.msg("Usage: teleport[/switches] [<obj> =] <target_loc>|home")
+            caller.msg("Usage: teleport[/switches] [<obj> =] <target_loc>||home")
             return
 
         if rhs:
@@ -2384,6 +2386,11 @@ def func(self):
         if not destination:
             caller.msg("Destination not found.")
             return
+        if to_loc:
+            destination = destination.location
+            if not destination:
+                caller.msg("Destination has no location.")
+                return
         if obj_to_teleport == destination:
             caller.msg("You can't teleport an object inside of itself!")
             return


Test patch: