From 60708b03dfeb328ea936fa4270807087693d2051 Mon Sep 17 00:00:00 2001 From: DeltaFire Date: Wed, 24 Feb 2021 05:16:15 +0100 Subject: [PATCH] check --- .../game/machinery/computer/buildandrepair.dm | 6 ---- code/game/machinery/constructable_frame.dm | 29 ++++++++++--------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/code/game/machinery/computer/buildandrepair.dm b/code/game/machinery/computer/buildandrepair.dm index 280348368d..00ba621550 100644 --- a/code/game/machinery/computer/buildandrepair.dm +++ b/code/game/machinery/computer/buildandrepair.dm @@ -117,12 +117,6 @@ if(user.a_intent == INTENT_HARM) return ..() -//callback proc used on stacks use_tool to stop unnecessary amounts being wasted from spam clicking. -/obj/structure/frame/computer/proc/check_state(target_state) - if(state == target_state) - return TRUE - return FALSE - /obj/structure/frame/computer/deconstruct(disassembled = TRUE) if(!(flags_1 & NODECONSTRUCT_1)) if(state == 4) diff --git a/code/game/machinery/constructable_frame.dm b/code/game/machinery/constructable_frame.dm index b00edfd82c..d5bbcb0adc 100644 --- a/code/game/machinery/constructable_frame.dm +++ b/code/game/machinery/constructable_frame.dm @@ -21,6 +21,11 @@ circuit = null qdel(src) +//callback proc used on stacks use_tool to stop unnecessary amounts being wasted from spam clicking. +/obj/structure/frame/proc/check_state(target_state) + if(state == target_state) + return TRUE + return FALSE /obj/structure/frame/machine name = "machine frame" @@ -84,7 +89,7 @@ if(!P.tool_start_check(user, amount=5)) return to_chat(user, "You start to add cables to the frame...") - if(P.use_tool(src, user, 20, volume=50, amount=5)) + if(P.use_tool(src, user, 20, volume=50, amount=5, extra_checks = CALLBACK(src, .proc/check_state, 1))) to_chat(user, "You add cables to the frame.") state = 2 icon_state = "box_1" @@ -93,25 +98,23 @@ if(P.tool_behaviour == TOOL_SCREWDRIVER && !anchored) user.visible_message("[user] disassembles the frame.", \ "You start to disassemble the frame...", "You hear banging and clanking.") - if(P.use_tool(src, user, 40, volume=50)) - if(state == 1) - to_chat(user, "You disassemble the frame.") - var/obj/item/stack/sheet/metal/M = new (loc, 5) - M.add_fingerprint(user) - qdel(src) + if(P.use_tool(src, user, 40, volume=50, extra_checks = CALLBACK(src, .proc/check_state, 1))) + to_chat(user, "You disassemble the frame.") + var/obj/item/stack/sheet/metal/M = new (loc, 5) + M.add_fingerprint(user) + qdel(src) return if(P.tool_behaviour == TOOL_WRENCH) to_chat(user, "You start [anchored ? "un" : ""]securing [name]...") - if(P.use_tool(src, user, 40, volume=75)) - if(state == 1) - to_chat(user, "You [anchored ? "un" : ""]secure [name].") - setAnchored(!anchored) + if(P.use_tool(src, user, 40, volume=75, extra_checks = CALLBACK(src, .proc/check_state, 1))) + to_chat(user, "You [anchored ? "un" : ""]secure [name].") + setAnchored(!anchored) return if(2) if(P.tool_behaviour == TOOL_WRENCH) to_chat(user, "You start [anchored ? "un" : ""]securing [name]...") - if(P.use_tool(src, user, 40, volume=75)) + if(P.use_tool(src, user, 40, volume=75, extra_checks = CALLBACK(src, .proc/check_state, 2))) to_chat(user, "You [anchored ? "un" : ""]secure [name].") setAnchored(!anchored) return @@ -169,7 +172,7 @@ if(P.tool_behaviour == TOOL_WRENCH && !circuit.needs_anchored) to_chat(user, "You start [anchored ? "un" : ""]securing [name]...") - if(P.use_tool(src, user, 40, volume=75)) + if(P.use_tool(src, user, 40, volume=75, extra_checks = CALLBACK(src, .proc/check_state, 3))) to_chat(user, "You [anchored ? "un" : ""]secure [name].") setAnchored(!anchored) return