can someone tell me the difference ?
src.ki=9
usr.ki=9
ID:141487
Feb 20 2009, 12:16 pm
|
|
Feb 20 2009, 12:25 pm
|
|
src always refers to what the proc is defined under, and is always defined as such unless this is explicitly changed by the programmer (i.e., manually setting the value of src to something different). On the other hand, usr is set when a player initiates an action, which is the reason it generally works in verbs and things like Click() (often called pseudo-verbs). If any of these are manually called by the programmer, then usr is not set to anything, and you'll get an error saying that usr is null (stuff like null.variable or stuff like that).
|
In response to Popisfizzy
|
|
ok
|
That question completely lacks context, but look them up in the DM Reference (also available through pressing F1 in Dream Maker); src and usr are 2 completely different vars.
usr is the mob of the player that started up the current chain of procs <small>(verbs are also procs)</small> by initiating an action (such as executing a verb). This var is automatically and implicitly passed between procs like a hidden argument. It can easily be null if the current proc wasn't ultimately initiated by a player. It is mostly either unsafe or not robust to use anywhere outside verbs and verb-like functions (like the mouse procs) unless one really knows what he's doing. src on the other hand is the object (could be any type of object; also mind the distinction from obj) that the current proc is attached to and runs on, or null if there is none (if it's a global function). If this object is deleted the current proc (and any other procs running on the same object) will automatically end. There is a shorthand in the compiler for accessing src's properties (procs and vars); you can simply write their name without explicitly writing "src." and if the result is an undefined var/proc then Dream Maker will check if src has such a property, and if so it will use it. So you can write health -= 5 instead of src.health -= 5 and the compiler will take it as the same. |