ID:142605
 
Code:
obj/Items
Candle
var
Owner
Lit = 0
icon = 'objects.dmi'
icon_state = "candle"
verb
Use()
if(Lit)
Lit = !Lit
icon_state = "candle"
usr << "You blow out the candle."
Owner = usr
else
Lit = TRUE
icon_state = "candle_lit"
usr << "You light the candle."
Owner = usr

world/New()
..()
spawn() Candles()

Candles()
while(world)
sleep(10)
for(var/area/Weather/w in world)
world << w
for(var/obj/Items/Candle/o in world)
if(o.Lit)
for(var/area/Weather/w in view(4,o.Owner))
w.icon_state="dark2"


Problem description:
For my game, I have an area called "Weather" that is every where. During the day time, it's icon_state is equal to "dark0". During the night, "dark7". I'm trying to make a simple proc that will change the Weathers that are within 4 spaces of the candle's icon_state to be equal to "dark2". I have only tried using the method above, as I cannot think of another way it can be done. Any help would be appreciated.

**EDIT**
I've debugged some and it turns out that it treats the Weather as a single instance, instead of each being a separate instance.
If you want to do things the way you're doing them, the only solution would be to move the turfs near the candle to a new area. This is something that tends to get confusing really quickly. Here's a simple case, which may or may not work for you, depending on how you use the areas:

area
Weather
Illuminated


obj/Items/Candle
verb/Use()
Lit = !Lit
if(Lit)
for(var/turf/T in oview(src,4))
if(istype(T.loc, /area/Weather))
new /area/Illuminated(T) //does not actually create a new area if there's already an /area/Illuminated
else
for(var/turf/T in oview(src,4))
if(istype(T.loc, /area/Illuminated))
new /area/Weather(T)


The Illuminated area would switch between dark0 and dark2, and the Weather area would switch between dark0 and dark7.

Also:

I've debugged some and it turns out that it treats the Weather as a single instance, instead of each being a separate instance.

That's how areas work.
Michael3131 wrote:
I've debugged some and it turns out that it treats the Weather as a single instance, instead of each being a separate instance.

As with anything, look things up in the DM Reference before you use them.