From ac49debfceccc685c439ac1b135a55b7d99bbcd2 Mon Sep 17 00:00:00 2001 From: joep van der velden Date: Sun, 31 May 2020 20:48:01 +0200 Subject: [PATCH] Make light_constructs use X_acts --- code/modules/power/lighting.dm | 127 +++++++++++++++++---------------- 1 file changed, 66 insertions(+), 61 deletions(-) diff --git a/code/modules/power/lighting.dm b/code/modules/power/lighting.dm index 78c2561ae7d..44967c5d4ed 100644 --- a/code/modules/power/lighting.dm +++ b/code/modules/power/lighting.dm @@ -39,81 +39,86 @@ if(3) . += "The casing is closed." -/obj/machinery/light_construct/attackby(obj/item/W as obj, mob/living/user as mob, params) - src.add_fingerprint(user) - if(istype(W, /obj/item/wrench)) - if(src.stage == 1) - playsound(src.loc, W.usesound, 75, 1) - to_chat(usr, "You begin deconstructing [src].") - if(!do_after(usr, 30 * W.toolspeed, target = src)) +/obj/machinery/light_construct/wrench_act(mob/living/user, obj/item/I) + . = TRUE + switch(stage) + if(1) + to_chat(user, "You begin deconstructing [src].") + if(!I.use_tool(src, user, 30, volume = I.tool_volume)) return - new /obj/item/stack/sheet/metal( get_turf(src.loc), sheets_refunded ) - user.visible_message("[user.name] deconstructs [src].", \ - "You deconstruct [src].", "You hear a noise.") - playsound(src.loc, W.usesound, 75, 1) + new /obj/item/stack/sheet/metal(get_turf(loc), sheets_refunded) + user.visible_message("[user.name] deconstructs [src].", \ + "You deconstruct [src].", "You hear a noise.") qdel(src) - if(src.stage == 2) - to_chat(usr, "You have to remove the wires first.") - return + if(2) + to_chat(user, "You have to remove the wires first.") + if(3) + to_chat(user, "You have to unscrew the case first.") - if(src.stage == 3) - to_chat(usr, "You have to unscrew the case first.") - return - - if(istype(W, /obj/item/wirecutters)) - if(src.stage != 2) return - src.stage = 1 - switch(fixture_type) - if("tube") - src.icon_state = "tube-construct-stage1" - if("bulb") - src.icon_state = "bulb-construct-stage1" - new /obj/item/stack/cable_coil(get_turf(src.loc), 1, paramcolor = COLOR_RED) - user.visible_message("[user.name] removes the wiring from [src].", \ - "You remove the wiring from [src].", "You hear a noise.") - playsound(loc, W.usesound, 100, 1) +/obj/machinery/light_construct/wirecutter_act(mob/living/user, obj/item/I) + if(stage != 2) return + . = TRUE + if(!I.use_tool(src, user, 0)) + return + playsound(loc, I.usesound, 100, 1) + . = TRUE + stage = 1 + switch(fixture_type) + if("tube") + icon_state = "tube-construct-stage1" + if("bulb") + icon_state = "bulb-construct-stage1" + new /obj/item/stack/cable_coil(get_turf(loc), 1, paramcolor = COLOR_RED) + user.visible_message("[user] removes the wiring from [src].", \ + "You remove the wiring from [src].", "You hear a noise.") + +/obj/machinery/light_construct/screwdriver_act(mob/living/user, obj/item/I) + if(stage != 2) + return + . = TRUE + if(!I.use_tool(src, user, 0)) + return + switch(fixture_type) + if("tube") + icon_state = "tube-empty" + if("bulb") + icon_state = "bulb-empty" + stage = 3 + user.visible_message("[user] closes [src]'s casing.", \ + "You close [src]'s casing.", "You hear a noise.") + playsound(loc, I.usesound, 75, 1) + + switch(fixture_type) + if("tube") + newlight = new /obj/machinery/light/built(loc) + if("bulb") + newlight = new /obj/machinery/light/small/built(loc) + + newlight.dir = dir + transfer_fingerprints_to(newlight) + qdel(src) + +/obj/machinery/light_construct/attackby(obj/item/W, mob/living/user, params) + add_fingerprint(user) if(istype(W, /obj/item/stack/cable_coil)) - if(src.stage != 1) return + if(stage != 1) + return var/obj/item/stack/cable_coil/coil = W coil.use(1) switch(fixture_type) if("tube") - src.icon_state = "tube-construct-stage2" + icon_state = "tube-construct-stage2" if("bulb") - src.icon_state = "bulb-construct-stage2" - src.stage = 2 + icon_state = "bulb-construct-stage2" + stage = 2 playsound(loc, coil.usesound, 50, 1) - user.visible_message("[user.name] adds wires to [src].", \ - "You add wires to [src].") + user.visible_message("[user.name] adds wires to [src].", \ + "You add wires to [src].") return - if(istype(W, /obj/item/screwdriver)) - if(src.stage == 2) - switch(fixture_type) - if("tube") - src.icon_state = "tube-empty" - if("bulb") - src.icon_state = "bulb-empty" - src.stage = 3 - user.visible_message("[user.name] closes [src]'s casing.", \ - "You close [src]'s casing.", "You hear a noise.") - playsound(src.loc, W.usesound, 75, 1) - - switch(fixture_type) - - if("tube") - newlight = new /obj/machinery/light/built(src.loc) - if("bulb") - newlight = new /obj/machinery/light/small/built(src.loc) - - newlight.dir = src.dir - src.transfer_fingerprints_to(newlight) - qdel(src) - return - else - return ..() + return ..() /obj/machinery/light_construct/blob_act(obj/structure/blob/B) if(B && B.loc == loc)