ID:160260
 
runtime error: Cannot read null.grank
proc name: Die (/proc/Die)
usr: Iruno (/mob)
src: null
call stack:
Die()
Iruno (/mob): Giant Sand Burial()

this is the two codes that that run time error has to do with
(btw says same things for every code that uses my Die() proc so i think it's the proc not the verb)

    GSandB()
set name = "Giant Sand Burial"
set category = "Jutsu"
if(usr.using==0)
for(var/mob/M in world)
if(M.gcoffin == 1)
if(M.gcoffinorigin == usr)
view() << "Giant Sand Burial...!!!!!!"
var/dmg = rand(usr.nin*10,usr.nin*15)
view() << "[M] took [dmg] damage from [M.gcoffinorigin]'s Sand Burial!"
M.overlays -= 'icons/kyuu.dmi'
flick('sandburial.dmi',M)
M.gcoffin = 0
M.gcoffinorigin = ""
M.canmove = 1
usr.canmove = 1
M.hp -= dmg
Die()

proc
Die()
for(var/mob/E in world)
if(E.hp <= 0)
if(E.grank == "Clone")
flick('smoke.dmi',E)
sleep(10)
del(E)
if(E.grank == "Mob")
view()<<"[usr] kills [E.name]."
usr<<"You kill the [E.name]"
if(E.eexp >= 1)
usr.exp += E.eexp
usr<<"You you gain [E.eexp] experience from the [E.name]"
Levelup()
del(E)
if(E.grank == "Player")
usr.kills += 1
view()<<"[usr] kills [E.name]."
usr<<"You kill [E.name]"
Levelup()
Your grank is null and you don't have an "if(grank == null)" if statement set so it'll give you a runtime error. Or at least that what I believe is the problem.
Did you really mean to create /proc/Die() or did you want something else? Perhaps /mob/proc/Die()?
In response to Jon88
Jon88 wrote:
Did you really mean to create /proc/Die() or did you want something else? Perhaps /mob/proc/Die()?

yea i meant proc/die not mob/proc/die cause i use this proc with objs too
In response to Mizukouken Ketsu
Mizukouken Ketsu wrote:
Your grank is null and you don't have an "if(grank == null)" if statement set so it'll give you a runtime error. Or at least that what I believe is the problem.

i'll try it and tell ya what happens but not tottaly sure what u mean :P

heres some other stuff that have to do with it

mob/var
grank = ""

mob
NPC
icon = 'icons/Guards.dmi'
icon_state = "Guard Leaf/Grass"
name = "Rouge Ninja (Genin)"
grank = "Mob"
tai = 1
nin = 1
gen = 1
hp = 10
mhp = 10
def = 2
eexp = 10
canmove = 1
New()
..()
spawn()MOVE()
proc
MOVE()
if(src.canmove == 1)
Die() //heres the die proc again but i suppose it works here
if(src)
step_rand(src)
spawn(30)
MOVE()


1 thing to tell u, even though i get the runtime error the code still works correctly (i think) :P
In response to IrunoHatake
Yeah the mob/var/grank="" is the problem. Since your proc doesn't have an "if(grank == "")", you're going to get the runtime error and anything under those if(grank=="whatever")" statements, aren't going to happen.
In response to IrunoHatake
No usr in procs.
In response to Andre-g1
Naruto Path of Kage.dm:743:error:src.exp:undefined var
Naruto Path of Kage.dm:748:error:src.kills:undefined var

thats the prob i got when i did src so can i use usr there?
In response to Mizukouken Ketsu
so what ur saying is this?

proc
Die()
for(var/mob/E in world)
if(E.hp <= 0)
if(E.grank == "")
return
else
if(E.grank == "Clone")
flick('smoke.dmi',E)
sleep(10)
del(E)
if(E.grank == "Mob")
view()<<"[src] kills [E.name]."
src<<"You kill the [E.name]"
if(E.eexp >= 1)
src.exp += E.eexp
src<<"You you gain [E.eexp] experience from the [E.name]"
Levelup()
del(E)
if(E.grank == "Player")
src.kills += 1
view()<<"[src] kills [E.name]."
src<<"You kill [E.name]"
Levelup()
In response to IrunoHatake
What you should be using is the var you defined on the for().

E.
In response to IrunoHatake
*sigh* Read carefully.

runtime error: Cannot read null.grank

E.grank

So, E is null, and there is no "null.grank". Now, inspect this part of the code:

                    if(E.grank == "Clone")
flick('smoke.dmi',E)
sleep(10)
del(E)
if(E.grank == "Mob")


Think, what happens here. Let us assume, E.grank is "Clone". It will then change the icon to 'smoke.dmi', wait a second, and delete E.

OK, so now the mob is deleted. But: It goes on, checking if E.grank is "Mob". But E does not exist anymore, so it will throw a runtime error. This is why you need to use "else if" here, or terminate the proc with "return".

                    if(E.grank == "Clone")
flick('smoke.dmi',E)
sleep(10)
del(E)
else if(E.grank == "Mob")
In response to CIB
wow........ omg so simple.... i forgot else..... infact i just made a code with a bunch of elses w/e thank you
In response to CIB
With the checking he's doing, he'd probably be better off using a switch() statement instead of if/else if/else statements.

I also recommend looking up the various uses of the ! operator. Checks like if(variable == ""), if(variable == 0) or if(variable == null) can be done just as if(!variable).

(You should also note that "", 0 and null aren't the same value, and there are rare circumstances when the programmer might want to know the difference between them.)