diff --git a/code/game/machinery/lightswitch.dm b/code/game/machinery/lightswitch.dm index c5799d8b4eb..3cdc66ae490 100644 --- a/code/game/machinery/lightswitch.dm +++ b/code/game/machinery/lightswitch.dm @@ -12,6 +12,8 @@ var/area/area = null ///Range of the light emitted when powered, but off var/light_on_range = 1 + /// Should this lightswitch automatically rename itself to match the area it's in? + var/autoname = TRUE /obj/machinery/light_switch/Initialize(mapload) . = ..() @@ -30,11 +32,22 @@ MAPPING_DIRECTIONAL_HELPERS_ROBUST(/obj/machinery/light_switch, 32, -18, 33, -33 if(!area) area = get_area(src) - if(!name) - name = "light switch ([area.name])" + if(autoname) + name = "[area.name] light switch" + register_context() update_appearance() +/obj/machinery/light_switch/add_context(atom/source, list/context, obj/item/held_item, mob/user) + . = ..() + if(isnull(held_item)) + context[SCREENTIP_CONTEXT_LMB] = area.lightswitch ? "Flick off" : "Flick on" + return CONTEXTUAL_SCREENTIP_SET + if(held_item.tool_behaviour == TOOL_SCREWDRIVER) + context[SCREENTIP_CONTEXT_RMB] = "Deconstruct" + return CONTEXTUAL_SCREENTIP_SET + return . + /obj/machinery/light_switch/update_appearance(updates=ALL) . = ..() luminosity = (machine_stat & NOPOWER) ? 0 : 1 @@ -57,11 +70,19 @@ MAPPING_DIRECTIONAL_HELPERS_ROBUST(/obj/machinery/light_switch, 32, -18, 33, -33 /obj/machinery/light_switch/examine(mob/user) . = ..() . += "It is [(machine_stat & NOPOWER) ? "unpowered" : (area.lightswitch ? "on" : "off")]." + . += span_notice("It is screwed in place.") /obj/machinery/light_switch/interact(mob/user) . = ..() set_lights(!area.lightswitch) +/obj/machinery/light_switch/attackby_secondary(obj/item/weapon, mob/user, params) + if(weapon.tool_behaviour == TOOL_SCREWDRIVER) + to_chat(user, "You pop \the [src] off the wall.") + deconstruct() + return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN + return ..() + /obj/machinery/light_switch/proc/set_lights(status) if(area.lightswitch == status) return