ID:147857
 
this is the click obj i use to teleport to someone.

obj
Skills
Instant_Transmission
icon = 'HUDPanel.dmi'
icon_state = "Instant Transmission"
Click()
Teleport()
proc/Teleport(mob/M in world){set category="Admin";set desc="Who do you wish to teleport to?";usr.loc=M.loc;world.log<<"[usr] teleported to [M].";view()<<"[usr] appeared in a flash."}

it has an error. but i dont know what it means.

runtime error: Cannot read null.loc
proc name: Teleport (/obj/Skills/Instant_Transmission/proc/Teleport)
usr: Dark Legend (/mob/Saiyin)
src: Instant Transmission (/obj/Skills/Instant_Transmission)
call stack:
Instant Transmission (/obj/Skills/Instant_Transmission): Teleport(null)
Instant Transmission (/obj/Skills/Instant_Transmission): Click("Battle")
In a proc, don't assume usr means anything. in this case, because of the Click() it does, bleh.
http://byondscape.com/ascape.dmb/LummoxJR.2002-1104/

This is Lummox's usr un-friendly article. Read this, it will teach you the do's and don'ts of using usr. i should probably read it again..


Trog
In response to Troglodyte
Actually in that perticular case usr is valid, without passing arguements he can't use src in place of usr (src is the obj).

The problem is if M is null, it will not be able to read it. Simple fix is to stick something like

if(!M)
usr<<"Cannot find who you wish to teleport to!"
return

Which tells it if M is false or null, return, if not do everything else
In response to Nick231
Both of you are wrong. The problem is that he never gets input for where he wants to teleport to.
In response to Garthor
Ture... Although it wouldn't hurt at all to put the if(!M) check in..