ID:263184
 
Code:
mob/proc/Death()
var/obj/M = usr
usr.Experience += src.Experience
if(usr.Energy<= 0)
..()


Problem description:
Well the problem is i keep getting a warning message from this piece of coding, how can i get the warning to be fix.
The warning message say's this


loading NAG.dme
Death System.dm:517:M :warning: variable defined but not used
loading Original Map.dmp
saving NAG.dmb (DEBUG mode)

NAG.dmb - 0 errors, 1 warning (double-click on an error to jump to it)
I didn;t test it but I am pretty sure it should be
mob/proc/Death()
var/mob/M = usr
usr.Experience += src.Experience
if(usr.Energy<= 0)
..()
In response to Dragon warrior2662
yeah but i did test it and it says

loading NAG.dme
Death System.dm:516:M :warning: variable defined but not used
loading Original Map.dmp
saving NAG.dmb (DEBUG mode)

NAG.dmb - 0 errors, 1 warning (double-click on an error to jump to it)
Sayian Hunter wrote:
Code:
> mob/proc/Death()
> var/obj/M = usr
> usr.Experience += src.Experience
> if(usr.Energy<= 0)
> ..()
>

Problem description:
Well the problem is i keep getting a warning message from this piece of coding, how can i get the warning to be fix.
The warning message say's this


loading NAG.dme
Death System.dm:517:M :warning: variable defined but not used
loading Original Map.dmp
saving NAG.dmb (DEBUG mode)

NAG.dmb - 0 errors, 1 warning (double-click on an error to jump to it)

no put usr in proc. ungh

mob
proc
Deathcheck(mob/X)
var/mob/player/M
while(src.hp==0)
if(istype(,/mob/player))
src.locate=loc("Checkpoint")
else
M.exp+= 50
del(src)

Useful Tools:-
DM Reference

DM Guide
In response to Talion Knight
No put usr in proc, ungh.
In response to Pyro_dragons
I didn't, that was his code!
In response to Talion Knight
M.exp+= 50


You know you didn't define M there and X in the args of the proc was totally ignored :X

Anyways, the warning is saying exactly the problem: You (the person who made this thread) made the variable mob/M but you never defined who was this mob/M nor was it used anywhere in that code (meaning it's useless)

Simple solution to a simple problem: Delete the unused variable...

- GhostAnime
The defined variable, "M", is not being used -- and therefor an error is generated. And why did you make it an obj? =/

But that's still a bad method -- you don't even need to define M, you're wasting bytes! And src would be the correct use there, as usr is unsafe in such procs.

And also a bit of structural advice, in a Death() (I assume you're using it as a deathcheck() proc) proc, you should always have the killer also defined.

mob/verb/kill(mob/M in world)
M.hp=0
M.death(src)

mob/proc/death(mob/M) //M is the killer here, and src the killed mob.
if(src.hp>0) return // if the hp is more than 0 it stops the procedure.
M<<"You killed [src]"
src<<"You've been killed by [M] -- you will be deleted in a few seconds!"
sleep(12)
del(src) // deletes the killed mob


That is the best method to handle death in a game, I believe.

O-matic