Files
GS13NG/code/game/machinery/lightswitch.dm
Ghom 7c7147cb3e Field of Vision component. (#12075)
* Hopeless WIP for vision cones.

* Core component and hooks done

* Removing clutter.

* linter bashing me for using statements as args.

* Ok.

* continue

* bring back the macro

* Configs and openspace filter.

* Chat plane, reset perspective signal, mechs/vehicles cases, machineries.

* view, viewers and spoopy ghosts.

* Renamed component, admin fun button and snowflakes robots.

* Whoopsie.

* Yikes

* test merge tweak.

* radial yaketi sax.

* Fixed tgui UIs, some messages not displayed to the target.

* Documentation and a little bugfix.

* Pulling QoL, seventh plane made in this PR.

* Fix.

* Tweaks and improvements.

* Update randomverbs.dm
2020-05-15 15:25:04 -07:00

69 lines
1.3 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"
icon = 'icons/obj/power.dmi'
icon_state = "light1"
plane = ABOVE_WALL_PLANE
desc = "Make dark."
var/on = TRUE
var/area/area = null
var/otherarea = null
/obj/machinery/light_switch/Initialize()
. = ..()
area = get_area(src)
if(otherarea)
area = locate(text2path("/area/[otherarea]"))
if(!name)
name = "light switch ([area.name])"
on = area.lightswitch
update_icon()
/obj/machinery/light_switch/update_icon_state()
if(stat & NOPOWER)
icon_state = "light-p"
else
if(on)
icon_state = "light1"
else
icon_state = "light0"
/obj/machinery/light_switch/examine(mob/user)
. = ..()
. += "It is [on? "on" : "off"]."
/obj/machinery/light_switch/interact(mob/user)
. = ..()
on = !on
area.lightswitch = on
area.update_icon()
for(var/obj/machinery/light_switch/L in area)
L.on = on
L.update_icon()
area.power_change()
/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 (. & EMP_PROTECT_SELF)
return
if(!(stat & (BROKEN|NOPOWER)))
power_change()