/ Each new client gets its own map_fade object.
client/New()
..()
src.screen += new/map_fade
// This is the fade object that is used by the library - each client gets one.
// It will automatically be added to the client's screen and it will change
// truanslucency dependant on the client's current fade settings.
map_fade
parent_type = /atom/movable
icon = 'fade_gradient.dmi'
icon_state = "0"
screen_loc = "NORTHWEST to SOUTHEAST"
// Defaults to 255, but this can be altered with the fade.MapLayer() proc.
layer = 90001
My Code:
mob/proc/Daystart() //I made each of these 'mob/proc' it affects mobs.
fade.Map(src, 63, 2, 50) //from 12am to 3
mob/proc/Dayend()
fade.Map(src, 127, 2, 50) //from 3 to 6
mob/proc/Sunsetstart()
fade.Map(src, 191, 2, 50) //from 6 to 9
mob/proc/Sunsetend()
fade.Map(src, 255, 2, 50) //from 9 to 12am
mob/proc/Nightstart()
fade.Map(src, 191, 2, 50) //from 12am to 3
mob/proc/Nightend()
fade.Map(src, 127, 2, 50) //from 3 to 6
mob/proc/Sunrisestart()
fade.Map(src, 63, 2, 50) //from 6 to 9
mob/proc/Sunriseend()
fade.Map(src, 0, 2, 50) //from 9 to 12pm
proc/DayCycle() //This proc is called under World/New() so it starts when the world is online.
daytime = "Day" //var/daytime is already declared elsewhere in the code. It's displayed to all mobs with clients in their Status tab
sleep(10) //using sleep() instead of spawn() so these procs are run in order
for(var/mob/M in world) //this is where I thought the Night/Day system would affect mobs :(
if(!M.client) return
M.Daystart()
daytime = "Afternoon"
sleep(10)
for(var/mob/M in world)
if(!M.client) return
M.Dayend()
daytime = "Evening"
sleep(10)
for(var/mob/M in world)
if(!M.client) return
M.Sunsetstart()
daytime = "Dusk"
sleep(10)
for(var/mob/M in world)
if(!M.client) return
M.Sunsetend()
daytime = "Night"
Day++ //This var is declared elsewhere
YearCheck() //This proc is declared elsewhere. It just checks what number day it is and if it's 32, it brings Day==1 and raises the
//Month var by 1 increment, then checks to see if the month==12, and if it is it makes month==12,and raises the Year var by 1 increment.
sleep(10)
for(var/mob/M in world)
if(!M.client) return
M.Nightstart()
daytime = "Early Morning"
sleep(10)
for(var/mob/M in world)
if(!M.client) return
M.Nightend()
daytime = "Dawn"
sleep(10)
for(var/mob/M in world)
if(!M.client) return
M.Sunrisestart()
daytime = "Morning"
sleep(10)
for(var/mob/M in world)
if(!M.client) return
M.Sunriseend()
DayCycle() //repeats the Daycycle() proc
Problem description: Hey there. I know my code isn't the most efficient/best night/day method. It has no errors, but it doesn't work. I made sure the layer of map_fade(in Foomer's code) was higher than every other layer (I'll worry about interior areas later). It just doesn't really initialize from what I can see. After waiting about 20 seconds I'll right click the map (during runtime) and check the edit sheet of map_fade and it's icon_state is still 0 (which is when it's clear as day). I don't know why it doesn't cycle through the day.