ID:146360
 
Game Code Problem for some reason i get this error message while i am playing my game in offline mode

runtime error: Cannot modify null.sparing.
proc name: daycycle (/area/outside/proc/daycycle)
source file: weather.dm,52
usr: null
src: the outside (/area/outside)
call stack:
the outside (/area/outside): daycycle()
the outside (/area/outside): daycycle()

On line 52 i have

                    usr.sparing=-2


Got any ideas on how to fix this?


By giving us some more information perhaps? Show us the daycycle proc; and the proc/verb/thing "usr.sparing=-2" is in.

Probably, it's yet another usr abuse.

...don't you mean "usr.sparing-=2"?

*shrug*
In response to Phoenix Man
here it s

mob/var/stamina1=100
mob/var/sparing=-1


world
area = /area/outside // make outside the default area

New() // When the world begins
..() // do the regular things
for(var/area/outside/O in world) // Look for outside areas
spawn() O.daycycle() // begin the daycycle


area
outside // lay this area on the map anywhere you want it to change from night to day
layer = 6 // set this layer above everything else so the overlay obscures everything
var
lit = 1 // determines if the area is lit or dark.
obj/weather/Weather // what type of weather the area is having
proc
daycycle()
lit = 1 - lit // toggle lit between 1 and 0
if(lit)
overlays -= 'black50.dmi' // remove the 50% dither
world<<"the world is dim"
overlays += 'black25.dmi' // add a 25% dither for a fading effect
sleep(5) // pause a moment
overlays -= 'black25.dmi' // remove the dither
world<<"the world darkens"
sleep(5) // pause a moment
else
overlays -= 'black50.dmi' // remove the 50% dither
world<<"the world is dim"
overlays += 'black25.dmi' // add a 25% dither for a fading effect
sleep(5) // pause a moment
overlays -= 'black25.dmi' // remove the dither
world<<"the world darkens"
spawn(20) daycycle() // change the 20 to make longer days and nights
if(lit)
overlays += 'rain.dmi' // add a 25% dither for a fading effect
world<<"the world condition rain..bleh bleh demonhunter"
sleep(5) // pause a moment
overlays -= 'rain.dmi' // remove the dither
world<<"the world darkens"
else
overlays += 'snow.dmi' // add a 25% dither for a fading effect
sleep(5) // pause a moment
overlays -= 'snow.dmi' // remove the dither
spawn(20) daycycle() // change the 20 to make longer days and nights
usr.sparing=-2
if(lit)
overlays -= 'black50.dmi' // add a 25% dither for a fading effect
sleep(5) // pause a moment
overlays -= 'black25.dmi' // remove the dither
usr<<"weather is finally clear"
sleep(50)
usr.stamina=-1
sleep(50)
usr.stamina=-1
sleep(50)
usr.stamina=-1
sleep(50)
usr.stamina=-1
sleep(50)
usr.stamina=-1
sleep(50)
usr.stamina=-1
sleep(50)
usr.stamina=-1
sleep(50)
usr.stamina=-1
SetWeather(WeatherType)
if(Weather) // see if this area already has a weather effect
if(istype(Weather,WeatherType)) return // no need to reset it
overlays -= Weather // remove the weather display
del(Weather) // destroy the weather object
if(WeatherType) // if WeatherType is null, it just removes the old settings
Weather = new WeatherType() // make a new obj/weather of the right type
overlays += Weather // display it as an overlay for the area
inside // a sample area not affected by the daycycle or weather
luminosity = 1

obj/weather
layer = 7 // weather appears over the darkness because I think it looks better that way
rain
icon = 'rain.dmi'
snow
icon = 'snow.dmi'


Thats the whole coding
In response to Govegtos
usr is null. I told you, usr is evil!

Do something like this whenever you change "usr.sparing".
for(var/mob/M in world)M.sparing=-2 //this will make it so that it'll loop through the world, and change every mobs sparing variable to -2


Usr. Pah! Shoulda known that usr was behind this. UsrIsEvil, arghh!
In response to Phoenix Man
and how i get this error

weathersystem.dm:46:error:usr.sparing:undefined va

                else
overlays += 'snow.dmi' // add a 25% dither for a fading effect
sleep(5) // pause a moment
overlays -= 'snow.dmi' // remove the dither
spawn(20) daycycle() // change the 20 to make longer days and nights
for(var/mob/M in world)M.sparing=-2
In response to Govegtos
If you can't even define a var then I personally suggest you read the DM guide.

mob/var
sparing


Yes, it's that simple.
In response to RavenHeart
Umm, just for confirmation, does

for(var/mob/M in world)


work? I always thought it was

for(mob/M in world)


Err, yeah. Just looking for confirmation.
In response to Govegtos
That's not line 46. Note that "usr.sparing" doesn't appear anywhere in there? I think you mean sparring, but that's beside the point. Find ou what usr is before using it. And then don't use it in procs. Bye-bye!