ID:146939
 
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
obj/weather/Weather // what type of weather the area is having



proc
daycycle()
if(lit.1)
overlays -= 'black50.dmi' // remove the 50% dither
overlays += 'black25.dmi' // add a 25% dither for a fading effect
sleep(3) // pause a moment
overlays -= 'black25.dmi' // remove the dither
if(lit.0)
overlays += 'black25.dmi' // add a 25% dither for a fading effect
sleep(3) // pause a moment
overlays -= 'black25.dmi' // remove the dither
overlays += 'black50.dmi' // add the 50% dither


/*
If you prefer real darkness (luminosity = 0), replace the daycycle() proc
with the one below. Using luminosity for outside darkness is better if
you want to use other light sources like torches.

daycycle()
luminosity = 1 - luminosity // toggle between 1 and 0
spawn(20) daycycle() // change the 20 to make longer days and nights
*/


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



mob/verb
change_area()
var/turf/T = loc
if(!T) return // for some reason, the mob is not on a turf.

if(istype(T.loc,/area/outside)) // if the turf is in an outside area
T.loc.contents -= T // remove the turf from the outside area
// This does NOT move the turf, only changes
// the area it is associated with.

var/area/inside/I
for(I in world) //find an inside area
break
if(!I) I = new() // if there are no inside areas, create one

I.contents += T // add the turf location to the inside area
usr << "This is an <b>inside</b> area now."

else // this turf isn't outside
T.loc.contents -= T // remove the turf from it's current area

var/area/outside/O
for(O in world) // look for an outside area
break
if(!O) O = new() // if there are no outside areas, create one

O.contents += T // place the turf in the outside area
usr << "This is an <b>outside</b> area now."

rain()
var/area/outside/O
for(O in world) // look for an outside area
break
if(!O) return // if there are no outside areas, stop
O.SetWeather(/obj/weather/rain)

snow()
var/area/outside/O
for(O in world) // look for an outside area
break
if(!O) return // if there are no outside areas, stop
O.SetWeather(/obj/weather/snow)

clear_weather()
var/area/outside/O
for(O in world) // look for an outside area
break
if(!O) return // if there are no outside areas, stop
O.SetWeather()

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'

world
proc
Repop_Incriment()
sleep(3000)
world << "<center><font color=white><font size=1>The sun sets, fields are now pitch black. It is now evening."
lit = 0 // toggle lit between 1 and 0
world.Repop()
sleep(3000)
world << "<center><font color=white><font size=1>The sun rises, fields are now light and active with life. It is now morning."
lit = 1 // toggle lit between 1 and 0
world.Repop()
Repop_Incriment()
world
New()
..()
Repop_Incriment()

area
var
lit = 0


Thats my code for repop, But it tells me that lit(twice for lit, since its used twice in the repop part) and lit.1 and lit.2 are both not defined.. Can anyone help please?
Change area/var/lit to just var/global/list. That should fix the undefined lit part. Also, I can't see anywhere that lit.1 or lit.2 would be defined, so you have a problem there.
you know..im just using day/night for the moment.

im not using the rain yet, but it will be put in. is it your day/night part, or the weather?
I'm not sure where you got the lit.0 and lit.1 stuff. The original daycycle() proc from that demo is:
            daycycle()
lit = 1 - lit // toggle lit between 1 and 0
if(lit)
overlays -= 'black50.dmi' // remove the 50% dither
overlays += 'black25.dmi' // add a 25% dither for a fading effect
sleep(3) // pause a moment
overlays -= 'black25.dmi' // remove the dither
else
overlays += 'black25.dmi' // add a 25% dither for a fading effect
sleep(3) // pause a moment
overlays -= 'black25.dmi' // remove the dither
overlays += 'black50.dmi' // add the 50% dither
spawn(20) daycycle() // change the 20 to make longer days and nights


Lit should be defined as an area var.

[edit] Actually, "lit = !lit" would be a better way to toggle the value on and off.
In response to Shadowdarke
Hazman wrote:
Change area/var/lit to just var/global/list. That should fix the undefined lit part. Also, I can't see anywhere that lit.1 or lit.2 would be defined, so you have a problem there.

Yeah, That worked, but that lit.1 and lit.0 was a pathetic attempt(Cause i cant do any better XD) To make it so that when lit = 0 its night and when lit = 1 its day..


Psychotic wrote:
you know..im just using day/night for the moment.

im not using the rain yet, but it will be put in. is it your day/night part, or the weather?

It has both in it + my Repop thingy. I tried to merge the day and night part with my repop, and i just kept the other parts. gonna move em to admin right now though. Hmm.. Do you think Administrator level 2 and 3 should have it? Or would it be a stupid idea to give it to level 1 too?

Edit: Level 3 being the best and level 1 being the worst
In response to Takaru
Takaru wrote:
I tried to merge the day and night part with my repop

Ah, that makes sense. You just need to tell your outside areas that they should update.
world
proc
Repop_Incriment()
sleep(3000)
world << "<center><font color=white><font size=1>The sun sets, fields are now pitch black. It is now evening."
lit = 0
for(var/area/outside/O)
A.daycycle()
world.Repop()
sleep(3000)
world << "<center><font color=white><font size=1>The sun rises, fields are now light and active with life. It is now morning."
lit = 1
for(var/area/outside/O)
A.daycycle()
world.Repop()
Repop_Incriment()

area
outside
proc
daycycle()
if(lit)
overlays -= 'black50.dmi' // remove the 50% dither
overlays += 'black25.dmi' // add a 25% dither for a fading effect
sleep(3) // pause a moment
overlays -= 'black25.dmi' // remove the dither
else
overlays += 'black25.dmi' // add a 25% dither for a fading effect
sleep(3) // pause a moment
overlays -= 'black25.dmi' // remove the dither
overlays += 'black50.dmi' // add the 50% dither

In response to Shadowdarke
it sais that A.daycycle():undefined var
In response to Takaru
Change the A to an O.
Read the code through instead of just copying and pasting it, and if you don't understand any of it, then tell us and we'll try and explain.
In response to Hazman
Lol. Yeah, changed it to O, Now it has no affect. The sun cant rise or set. It can still rain or snow though.