Files
Aurora.3/code/game/machinery/lightswitch.dm
LordFowl 8d436c4a03 Converts all necessary << outputs into the to_chat() macro. (#6076)
This PR will lead us towards the Promised Day, for in its wake there shall be much celebration and ecstasy as this world becomes a world suitable for developer hegemony. The first strike is thusly;

All << is converted into to_chat().
2019-03-10 23:39:03 +02:00

75 lines
1.6 KiB
Plaintext

// the light switch
// can have multiple per area
// can also operate on non-loc area through "otherarea" var
/obj/machinery/light_switch
name = "light switch"
desc = "It turns lights on and off. What are you, simple?"
icon = 'icons/obj/power.dmi'
icon_state = "light-p"
anchored = 1.0
var/on = 1
var/area/area = null
var/otherarea = null
// luminosity = 1
/obj/machinery/light_switch/Initialize()
. = ..()
src.area = get_area(src)
if(otherarea)
src.area = locate(text2path("/area/[otherarea]"))
if(!name)
name = "light switch ([area.name])"
src.on = src.area.lightswitch
update_icon()
/obj/machinery/light_switch/update_icon()
cut_overlays()
if(!(stat & NOPOWER))
holographic_overlay(src, icon, "light[on]-overlay")
if (!light_range || light_color != on ? "#82ff4c" : "#f86060")
set_light(2, 0.3, on ? "#82ff4c" : "#f86060")
else if (light_range)
set_light(FALSE)
/obj/machinery/light_switch/examine(mob/user)
if(..(user, 1))
to_chat(user, "A light switch. It is [on? "on" : "off"].")
/obj/machinery/light_switch/attack_hand(mob/user)
playsound(src, "switch", 30)
on = !on
area.lightswitch = on
for(var/obj/machinery/light_switch/L in area)
L.on = on
L.update_icon()
for (var/obj/machinery/light/L in area)
if (on)
L.stat &= ~POWEROFF
else
L.stat |= POWEROFF
L.update()
/obj/machinery/light_switch/power_change()
if(!otherarea)
if(powered(LIGHT))
stat &= ~NOPOWER
else
stat |= NOPOWER
update_icon()
/obj/machinery/light_switch/emp_act(severity)
if(stat & (BROKEN|NOPOWER))
..(severity)
return
power_change()
..(severity)