ID:144399
 
Code:
mob.Click(mob/M in oview(1))
if(M == usr)
return
else
view()<<"<font color = red><B>-[usr] attacks [M]!-"
M.HP -= (usr.Str - M.End)
usr.Stam -= 5


Problem description:Here's the problem; runtime error: undefined variable /turf/Grass3/var/End
proc name: Click (/mob/Click)
usr: Kay (/mob)
src: Kay (/mob)
call stack:
Kay (/mob): Click(Tales of Xenologia (5,5,1) (/turf/Grass3))
-Kay attacks Tales of Xenologia!- thats actully the turf. I'm trying to make it attack a person/mob. Please help.

Strong123488 wrote:
Code:
mob.Click(mob/M in oview(1))
> if(M == usr)
> return
> else
> view()<<"<font color = red><B>-[usr] attacks [M]!-"
> M.HP -= (usr.Str - M.End)
> usr.Stam -= 5
>

Here's a better way to code it.
mob/Click(var/mob/M in oview(1))
if(M == usr)
return
else
view()<<"<font color = red><B>-[usr] attacks [M]!-"
M.HP -= (usr.Str - M.End)
usr.Stam -= 5
the one calling Click() is the one being clicked(aka the source). M is a pointless argument. src should be the one clicked, and usr the one clicking.
In response to DivineO'peanut
DivineO'peanut wrote:
the one calling Click() is the one being clicked(aka the source). M is a pointless argument. src should be the one clicked, and usr the one clicking.

{{{ note: the argument isn't entirely pointless, but it isn't what they think it is, yeah. The argument is the location of the atom clicked - yeah, normally it IS useless as it equals src.loc - EXCEPT, if atom was clicked in a statpanel, the argument equals the name of that statpanel.
---just noticed--- turns out it isn't useless if the object wasn't clicked in a statpanel; the following is included in the reference entry for client/Click - yeah, they should of included it in atom/Click() too:
Note that due to network lag, it is possible when clicking on moving objects for the location of those objects to have changed by the time the Click() proc is executed. That is the reason for the Location argument. It tells you where the click originally took place.
) }}}


Yeah, damn, they both cracked me up, especially Killer with his "better coded" version (no difference really, and he didn't catch the bugs). :D Good stuff, good stuff.

Really, no offense to anybody, but BEFORE YOU ATTEMPT TO USE A PROC, LOOK IT UP IN THE REFERENCE AND UNDERSTAND IT FIRST.
If you don't understand what's in the reference, don't use the proc, and go read DM guides and tutorials, OR make a topic in How-To on how that proc should be used, rather than just trying random things to use it. The amount of people that do that (and also actually post it!) is ridiculous.
The reference is easily-available via quick F1 keypress for a GOOD REASON. It's also available on this very forum page on the sidebar, mind you!
In response to Kaioken
Kaioken wrote:
DivineO'peanut wrote:
the one calling Click() is the one being clicked(aka the source). M is a pointless argument. src should be the one clicked, and usr the one clicking.

{{{ note: the argument isn't entirely pointless, but it isn't what they think it is, yeah. The argument is the location of the atom clicked - yeah, normally it IS useless as it equals src.loc - EXCEPT, if atom was clicked in a statpanel, the argument equals the name of that statpanel.
---just noticed--- turns out it isn't useless if the object wasn't clicked in a statpanel; the following is included in the reference entry for client/Click - yeah, they should of included it in atom/Click() too:
Note that due to network lag, it is possible when clicking on moving objects for the location of those objects to have changed by the time the Click() proc is executed. That is the reason for the Location argument. It tells you where the click originally took place.
) }}}

True, however I was talking about this certain case. =P

Good find about the statpanel thing, I never knew about that! You just unknowingly gave me the solution for my problem. He he.


BTW, Killer, the var/ prefix for arguments makes no difference, really. =)
In response to DivineO'peanut
DivineO'peanut wrote:
Good find about the statpanel thing, I never knew about that! You just unknowingly gave me the solution for my problem. He he.

Awesome. =)
(No, no, I did it knowingly, I telephatically discovered you needed to detect which statpanel an object was clicked in. >_>)

BTW, Killer, the var/ prefix for arguments makes no difference, really. =)

He also made the huge difference of changing mob/Click() at the beginning to mob.Click() (which still works just the same but only more generally confusing). :)
In response to Kaioken
Expirimenting with things can be useful, too.

O-matic