ID:147272
 
mob
Click()
src.Look()
mob
proc
Look(var/mob/M as mob,look as text)
if(M.defense >= src.defense) look+="Its defense is higher than yours"
src << "[look]"
if(M.defense >= src.defense) look-="Its defense is higher than yours"
..()

I don't get how I can further define the target... Can someone assist me?
mob
Click()
src.Look()

You're calling src.Look() and passing in no parameters so M and look will be null.

mob
proc
Look(var/mob/M as mob,look as text)
if(M.defense >= src.defense) look+="Its defense is higher than yours"

M is null since you passed in nothing therefore you get the cannot read null.defense runtime error.

It's hard to tell exactly what you want since I don't know what M is supposed to be. It looks like M is supposed to be the mob which is being looked at and src is the player looking. This structure doesn't make much sense to me but if it's the case you need to call Look() in Click() like.
usr.Look(src)
I'm not exactly sure what the look variable is supposed to hold since its just outputed but if you want something non-null you'll nee to pass in whatever you want it to be.
In response to Theodis
Im trying to make it when you click a mob, it'll scan its stats, compare them to yours, and give you feedback.



EDIT: It also returns the proc right but I still get a runtime error. A mismatch error:

runtime error: type mismatch
proc name: Look (/mob/proc/Look)
source file: project.dm,40
usr: Zlegend2 (/mob)
src: Zlegend2 (/mob)
call stack:
Zlegend2 (/mob): Look(the mob (/mob), "Its defense is lower than your...")
the mob (/mob): Click(the bluefloor (8,15,1) (/turf/bluefloor))
In response to ZLegend
if it will help heres what i've done. Help anyone? It would be appreciated.

mob/var/list/look = list()
mob
verb
Check(var/mob/M as mob)
if(M.defense >= src.defense) usr.look+=("Its defense is higher than yours")
for(usr.look)
usr << usr.look
if(M.defense >= src.defense) usr.look-=("Its defense is higher than yours")
return..()
if(M.defense <= src.defense) usr.look+=("Its defense is lower than yours")
for(usr.look)
usr << usr.look
if(M.defense <= src.defense) usr.look-=("Its defense is lower than yours")
return..()
In response to ZLegend
bump. Come on. Some help please? I've looked on the forums for problems related to this but I become very confused in how some of those compare with mine.
In response to ZLegend
If you're calling Check() like a proc: You forgot to pass M to Check().

If you're using Check as a verb and the error still happens: Uh... it shouldn't let you use the verb without selecting a mob. =P
In response to ZLegend
here's a simpler way of doing what you've said:

mob
verb
Check(var/mob/M in oview(5))//oview 5 means if he's within the distance 5 from the checker
if(M.defense >= src.defense)
usr << "It's defense is higher than yours"
else
usr << "It's defense is lower than yours"


I think you just complicated things too much...

By the way, you said you wanted it so when u clicked a mob, it would do the things. If u want a click thing then try this:

mob
Click()
if(M.defense >= src.defense)
usr << "It's defense is higher than yours"
else
usr << "It's defense is lower than yours"
In response to Crispy
Ya, that's one of the things im having trouble remembering how to do... Check(M)

I think it goes like that but I don't know where to define M.

Here's the updated proc and problem:
mob
Click(var/mob/M)
usr.Check(M)

mob/var/list/check
mob/proc/Check(var/mob/M in oview(5))
if(M.defense>=usr.defense)
usr.check+="It has high defense."
if(M.defense<=usr.defense)
usr.check+="It has low defense."


I changed the usrs to srcs.


runtime error: undefined variable /turf/bluefloor/var/defense
proc name: Check (/mob/proc/Check)
source file: project.dm,35
usr: Zlegend2 (/mob)
src: Zlegend2 (/mob)
call stack:
Zlegend2 (/mob): Check(the bluefloor (8,15,1) (/turf/bluefloor))
the mob (/mob): Click(the bluefloor (8,15,1) (/turf/bluefloor))
In response to DeathAwaitsU
well im telling more than just defense. This is not the full coding in which im planning to do.

Also in that click. I want to call a proc so the action for click can be set by the user.