8ddc9677c7
* 1/4 done? maybe? * more * stuff * incremental stuff * stuff * stuff & things * mostly done but not yet * stuffing * stuffing 2: electric boogaloo * Git Commit and the Kingdom of the Crystal Skull * make it actually compile * found more stuff * fixes * fix AI laws appearing out of order * fix windows * should be the remaining stuff * this time for real * i guess it should compile too * fix sechuds
64 lines
1.4 KiB
Plaintext
64 lines
1.4 KiB
Plaintext
/// The light switch. Can have multiple per area.
|
|
/obj/machinery/light_switch
|
|
name = "light switch"
|
|
icon = 'icons/obj/power.dmi'
|
|
icon_state = "light1"
|
|
desc = "Make dark."
|
|
/// Set this to a string, path, or area instance to control that area
|
|
/// instead of the switch's location.
|
|
var/area/area = null
|
|
|
|
/obj/machinery/light_switch/Initialize()
|
|
. = ..()
|
|
if(istext(area))
|
|
area = text2path(area)
|
|
if(ispath(area))
|
|
area = GLOB.areas_by_type[area]
|
|
if(!area)
|
|
area = get_area(src)
|
|
|
|
if(!name)
|
|
name = "light switch ([area.name])"
|
|
|
|
update_icon()
|
|
|
|
/obj/machinery/light_switch/update_icon()
|
|
if(stat & NOPOWER)
|
|
icon_state = "light-p"
|
|
else
|
|
if(area.lightswitch)
|
|
icon_state = "light1"
|
|
else
|
|
icon_state = "light0"
|
|
|
|
/obj/machinery/light_switch/examine(mob/user)
|
|
. = ..()
|
|
. += "It is [area.lightswitch ? "on" : "off"]."
|
|
|
|
/obj/machinery/light_switch/interact(mob/user)
|
|
. = ..()
|
|
|
|
area.lightswitch = !area.lightswitch
|
|
area.update_icon()
|
|
|
|
for(var/obj/machinery/light_switch/L in area)
|
|
L.update_icon()
|
|
|
|
area.power_change()
|
|
|
|
/obj/machinery/light_switch/power_change()
|
|
if(area == get_area(src))
|
|
if(powered(LIGHT))
|
|
stat &= ~NOPOWER
|
|
else
|
|
stat |= NOPOWER
|
|
|
|
update_icon()
|
|
|
|
/obj/machinery/light_switch/emp_act(severity)
|
|
. = ..()
|
|
if (. & EMP_PROTECT_SELF)
|
|
return
|
|
if(!(stat & (BROKEN|NOPOWER)))
|
|
power_change()
|