ID:1259051
 
(See the best response by Zecronious.)
Code:
obj
portal_one
name = "Corpse"
icon_state = "Deadbody1"
verb/Examine()
set src in view(1)
usr.loc = locate(/obj/portal_two)
usr << "You stoop to examine the body."

portal_two
name = "Corpse"
icon_state = "Deadbody1"
verb/Examine()
set src in view(1)
usr.loc = locate(/obj/portal_one)
usr << "You stand back up."


Problem description:
Hello! So basically, the problem I'm having is every time I "Examine" the corpse, I'm teleported to the second location but my icon disappears and I'm unable to move. This puzzles me, as I don't try to change the players icon in anyway, nor do I try to stop their movement.

Any help would be appreciated!

Could you post before-and-after screenshots, please?
Best response
The problem is that locate(/obj/portal_two) doesn't do what you think it's doing. It returns the object that it locates, not the location of that object. So what you're doing is setting the player's location to the object itself which is equivalent to adding the player to it's contents.

When you add a player to the contents of an object it becomes your client.eye meaning that you start seeing what the object sees but you can't move because you're inside it and you can't see yourself because you're not on the map.

To stop this happening here's one approach:

            var/obj/portal_two/p = locate(/obj/portal_two) // Store the object you found
usr.loc = P.loc // Explicitly send the user to it's location

There are different ways but I tested this and it works.
Sorry for the late reply, but it works like a charm now! Thanks.
In response to Renparo
No problem. I've had it happen before.
There are different ways but I tested this and it works.

I wasn't saying this was the best way to do it.
Galactic Soldier wrote:
Leaving in that argument is not necessary, as it is implicit to the prototype, and doing so will just result in your code running slower.

Didn't know that, thanks. :)