I read somewhere that they make a huge diffrence when useing them in certin ways.
Can anyone explain the diffrences to me?
Thanks!
P.S sorry for all the posts - still learning :)
ID:167493
Mar 6 2006, 10:37 pm
|
|
In response to Jp
|
|
Jp seems to have covered things pretty good...
My personal rule is to simply never use usr unless I absolutely have to... And the only case I've ever absolutely needed to use it is in Click()... (I'd need to use it in DblClick(), too, but I never bother with that one) |
In response to SuperSaiyanGokuX
|
|
Actually, you don't absolutely have to there either. You could just alter client/Click.
client/Click(atom/object, location) |
In response to Loduwijk
|
|
Heh, I never thought of doing it that way... I just went the lazy route and stuck with the already-there functionality...lol
But, that settles it... usr really has no place in virtually anyone's code... I assume there are some cases where it might need to be used, but these are likely to be so esoteric, that the only ones who run into them are the ones who know well enough what they're doing to use it properly... So in the end, just don't use usr at all... [Edit:] Let me clarify myself a bit, though... I know it's acceptable under a handful of conditions, but since there are other, equally acceptable alternatives, it's just safer practice to simply avoid it altogether... It's far better to never use it, and therefore never misuse it, than it is to make a mistake in deciding where to use it... |
In response to SuperSaiyanGokuX
|
|
Except in a single instance. Verbs belonging to other objects.
obj/verb/ItsVerb() However, I usually like to setup games in such a way as to avoid using verbs belonging to other objects, so I almost never run into that. But other than that, yes; there isn't really any need for usr other than that single instance. |
Usr Unfriendly
Essentially, src is equal to the 'source' of the proc or verb, whereas usr is the ultimate caller of it - usr is only defined if a player, specifically, calls the proc or verb.
You really should think about each situation on its own merits, but the simple rule is this:
1 - usr is okay in verbs
2 - usr is okay in pseudoverbs - procs that can only be called by a player. Eg, Click(), client/Move()
3 - usr is never okay in a proc.
4 - usr is even more not okay in a movement proc.
I'll just write up a short example to give you an idea of the sort of error you can get:
Compile that with a map, place a mobs and a lava square on the map, and push the other mob into the lava. Notice that YOU receive the message if you push another mob into the lava - that isn't right at all.
Also, a few procs have a default argument of usr - you have to be careful using them in a proc, and specify the argument yourself. A list, that is probably NOT complete:
oview()
view()
range()
orange()
hearers()
viewers()
input()
alert()