ID:1813292
 
(See the best response by Ter13.)
Code:
sealingproc()
for(var/mob/M in world)
if(M.sealed==1&&M.con>80)
sleep(200)
new/obj/immortality(M.loc)
sleep(10)
new/obj/immortalityfire(M.loc)
sleep(1)
M.alpha=0
sleep(1)
new/obj/immortality(locate(M.sealer))
sleep(10)
new/obj/immortalityfire(locate(M.sealer))
sleep(1)
M.alpha=initial(alpha)
M.sealed=0
M.loc=(locate(M.sealer))
else
if(M.sealed==1&&M.con<80)
sleep(200)
new/obj/immortality(M.loc)
sleep(10)
new/obj/immortalityfire(M.loc)
sleep(1)
M.alpha=0
sleep(1)
new/obj/immortality(locate(M.sealer))
sleep(10)
new/obj/immortalityfire(locate(M.sealer))
sleep(1)
M.alpha=initial(alpha)
M.sealed=0
M.loc=(locate(M.sealer))
else
if(M.sealed==1&&M.con<60)
sleep(200)
new/obj/immortality(M.loc)
sleep(10)
new/obj/immortalityfire(M.loc)
sleep(1)
M.alpha=0
sleep(1)
new/obj/immortality(locate(M.sealer))
sleep(10)
new/obj/immortalityfire(locate(M.sealer))
sleep(1)
M.alpha=initial(alpha)
M.sealed=0
M.loc=(locate(M.sealer))

sealing()
if(sealingcd||swim||dead||resting||seals)return
var/list/choose=list()
for(var/mob/B in view(8))choose.Add(B)
var/cancel="Cancel"
choose+=cancel
var/mob/B=input("Who do you want to seal?") as null|anything in choose
if(!B||B==cancel)return
if(B.village=="[usr.village]")
src<<"<b><font color=white>You can't seal your fellow village members!"
return
usr.handseals(200,50)
if(!sealpass)return
sealingcd=1
for(var/obj/jutsu/uchiha/Sealing/M in src)timerjutsu(900,M)
spawn(900)sealingcd=0
B.freeze=1
new/obj/immortality(B.loc)
sleep(10)
new/obj/immortalityfire(B.loc)
sleep(1)
B.alpha=0
sleep(1)
new/obj/immortality(locate(20,10,6))
sleep(10)
new/obj/immortalityfire(locate(20,10,6))
sleep(1)
B.alpha=initial(alpha)
sleep(1)
B.loc=(locate(20,10,6))
B.freeze=0
B.sealed=1
B.sealer="[usr]"
B.sealingproc()


Problem description: I am trying to make B.sealer="[usr]" be used in M.loc=(locate(M.sealer)) to call the location of the sealer and "teleporting" the mob to the sealer's current location.

But it just teleports the mob to 0,0,0 in complete darkness, and when I teleport there and move the game crashes...


Best response
That's because you can't locate mobs by their name. You need to use a tag, a "\ref" macro, or another method of storing the sealer mob rather than their name.

You should read one of my latest snippet sundays.

It applies very specifically to your situation here. Particularly, pay attention to the addendum.

http://www.byond.com/forum/?post=1810538
Looks chinese to me at the moment, but if I am remotely correct by reading that I need to:

var/sealer = locate("sealer") and call that?

I've read it all the way through but can't make much sense of it all yet, mainly cause I am not the most seasoned coder yet :)