Fix nightmode (#1891)

changes:

Fixes nightmode.
This commit is contained in:
Lohikar
2017-03-18 13:02:58 -05:00
committed by skull132
parent e6655deb3d
commit 161457b079
5 changed files with 31 additions and 33 deletions

View File

@@ -10,7 +10,7 @@ var/datum/controller/process/night_lighting/nl_ctrl
/datum/controller/process/night_lighting/setup()
name = "night lighting controller"
schedule_interval = 3600 // Every 5 minutes.
schedule_interval = 5 MINUTES
nl_ctrl = src
@@ -18,34 +18,26 @@ var/datum/controller/process/night_lighting/nl_ctrl
// Stop trying to delete processes. Not how it goes.
disabled = 1
/datum/controller/process/night_lighting/preStart()
switch (worldtime2ticks())
if (0 to config.nl_finish)
deactivate()
if (config.nl_start to TICKS_IN_DAY)
activate()
var/time = worldtime2hours()
if (time <= config.nl_finish || time >= config.nl_start)
activate()
else
deactivate()
/datum/controller/process/night_lighting/doWork()
if (manual_override) // don't automatically change lighting if it was manually changed in-game
return
switch (worldtime2ticks())
if (0 to config.nl_finish)
if (isactive)
command_announcement.Announce("Good morning. The time is [worldtime2text()]. \n\nThe automated systems aboard the [station_name()] will now return the public hallway lighting levels to normal.", "Automated Lighting System", new_sound = 'sound/misc/bosuns_whistle.ogg')
deactivate()
if (config.nl_start to TICKS_IN_DAY)
if (!isactive)
command_announcement.Announce("Good evening. The time is [worldtime2text()]. \n\nThe automated systems aboard the [station_name()] will now dim lighting in the public hallways in order to accommodate the circadian rhythm of some species.", "Automated Lighting System", new_sound = 'sound/misc/bosuns_whistle.ogg')
activate()
else
if (isactive)
deactivate()
var/time = worldtime2hours()
if (time <= config.nl_finish || time >= config.nl_start)
if (!isactive)
command_announcement.Announce("Good evening. The time is [worldtime2text()]. \n\nThe automated systems aboard the [station_name()] will now dim lighting in the public hallways in order to accommodate the circadian rhythm of some species.", "Automated Lighting System", new_sound = 'sound/misc/bosuns_whistle.ogg')
activate()
else
if (isactive)
command_announcement.Announce("Good morning. The time is [worldtime2text()]. \n\nThe automated systems aboard the [station_name()] will now return the public hallway lighting levels to normal.", "Automated Lighting System", new_sound = 'sound/misc/bosuns_whistle.ogg')
deactivate()
// 'whitelisted' areas are areas that have nightmode explicitly enabled

View File

@@ -177,8 +177,8 @@ var/list/gamemode_cache = list()
var/ghost_interaction = 0
var/night_lighting = 0
var/nl_start = 19 * TICKS_IN_HOUR
var/nl_finish = 8 * TICKS_IN_HOUR
var/nl_start = 19
var/nl_finish = 8
var/comms_password = ""
@@ -629,10 +629,10 @@ var/list/gamemode_cache = list()
config.night_lighting = 1
if("nl_start_hour")
config.nl_start = text2num(value) * TICKS_IN_HOUR
config.nl_start = text2num(value)
if("nl_finish_hour")
config.nl_finish = text2num(value) * TICKS_IN_HOUR
config.nl_finish = text2num(value)
if("disable_player_mice")
config.disable_player_mice = 1