ID:263268
 
Code:
//Mist Proc

Mist()
var/area/Outside/O
if(O.ismist == 0)
O.ismist = 1
for(O in oview(src,45))
O.icon = 'Spells.dmi'
O.icon_state = "mist"
sleep(1800)
O.ismist = 0
O.icon = null
O.icon_state = null
break
else
return

//area
area
Outside
var
ismist = 0
israin = 0
issnow = 0

//verb

mob
verb
Mister()
usr.Mist()


Problem description:
Everytime I use the Mister verb, I get this error

runtime error: Cannot read null.ismist
proc name: Mist (/mob/proc/Mist)
usr: Dead_Demon (/mob/Player)
src: Dead_Demon (/mob/Player)
call stack:
Dead_Demon (/mob/Player): Mist()
Dead_Demon (/mob/Player): Mister()
Your problem lies in your mist proc:
        Mist()
var/area/Outside/O


You define O, but you don't set it to anything. By default, when you define a variable, it is set to null. That is why you're getting a "null.ismist" error.

To fix this, you have to use locate() to get the actual instance of the /area/Outside object.

However, I also notice that you're trying to make mist in a certain area. /area objects are a special type, and there is only one instance of the object in the world, even if you put them in different z levels. If you're trying to make mist in a certain area, looking at area objects wouldn't be such a good idea. Otherwise, if you want to make it misty everywhere outside, then it will work fine.

Mist()
var/area/Outside/O = locate() in world // find an instance of the area object in the world
if(O && !O.ismist) // if one is found, and it isn't already misty
O.ismist = 1
O.icon = 'Spells.dmi'
O.icon_state = "mist"
spawn(1800)
O.ismist = 0
O.icon null
O.icon_state = null


~~> Unknown Person
In response to Unknown Person
Thanks! Now I know how to fix the null.whatever runtime error :)
In response to Unknown Person
I haven't had time to fix my mist code until today, and I did, and nothing happens. I already checked to make sure I had the icon_state and such right. Am I calling the proc right?

        Mist()
var/area/Outside/O = locate() in world
if(O && !O.ismist)
O.ismist = 1
O.icon = 'Spells.dmi'
O.icon_state = "Mist"
spawn(1800)
O.ismist = 0
O.icon = null
O.icon_state = null
..()
mob
verb
Mister()
usr.Mist()
In response to Dead_Demon
This works:
mob
verb
Mister()
for(var/area/Outside/O in oview(45))
Mist(O)
proc
Mist(area/Outside/O)
if(!O.ismist)
O.ismist = 1
O.icon = 'Spells.dmi'
O.icon_state = "mist"
sleep(1800)
O.ismist = 0
O.icon = null
O.icon_state = null
else return

But if you can't see it you need to set the areas layer like this:
area
Outside
layer=MOB_LAYER+2 //Sets the Outside area's layer 2 above the mob's layer
var
ismist = 0
israin = 0
issnow = 0
In response to Hellsing4
oO Whoops. Thanks
In response to Dead_Demon
your welcome