ID:265895
 
Okay here's a good question as far as I'm concerned... Is it better to use a colon (:) or typecast when referencing the usr of a Click() proc when calling a mob proc?

Example
turf/DblClick()
var/mob/Player/P = usr
P.Move(src)
P.Proc()

//OR...

turf/DblClick()
usr.Move(src)
usr:Proc()
Your typecasting example is useless. All it is is a veiled reference to usr. It's like putting a handgun in a cloth, then saying to the officers dragging you off an airplane, "No officer, see?! It's totally different!"

As well, your second example has no reason at all to be using the : operator. The . operator will work absolutely fine.
In response to Popisfizzy
Popisfizzy wrote:
Your typecasting example is useless. All it is is a veiled reference to usr. It's like putting a handgun in a cloth, then saying to the officers dragging you off an airplane, "No officer, see?! It's totally different!"

As well, your second example has no reason at all to be using the : operator. The . operator will work absolutely fine.

Mouse.dm:10:error:usr.Proc:undefined proc

Orly? >_>
In response to Mizukouken Ketsu
... or so I thought. Apparently usr isn't set as the typepath of the player. In this case, I'd go with the typecasting situation.
In response to Popisfizzy
Which is all I asked as an answer really. If you have an explanation, I'd love to hear (read o.O) it. ^_^ Thanks.
In response to Popisfizzy
It isn't really possible for it to be set to the correct path automatically; unlike with src, there's basically no way for DM to figure out what type the usr player object would be, so that var is statically defined as /mob.

You'd need to typecast, and I'd probably even throw a type check there to be safe, or instead make sure a player can't become another mob type (of course, this will probably often go out of the window if you have something like a skill allowing to possess monsters, but not always). Luckily enough, there's no way for the Login() proc to be skipped when a player logs into a mob, so it's actually rather foolproof to do that easily.