From fae398ae421747afddfa3f659af6b002df6929fd Mon Sep 17 00:00:00 2001 From: KasparoVy Date: Sun, 13 Nov 2016 18:16:37 -0500 Subject: [PATCH] Replaces \blue and \red with spans, removes unnecessary SRCs and :s, Fixes Negative Cable Coil Bug --- .../helper_datums/construction_datum.dm | 29 +- .../game/machinery/computer/buildandrepair.dm | 268 ++++++++++-------- code/game/machinery/constructable_frame.dm | 14 +- 3 files changed, 169 insertions(+), 142 deletions(-) diff --git a/code/datums/helper_datums/construction_datum.dm b/code/datums/helper_datums/construction_datum.dm index 6498f16c0d3..0a17435c5c0 100644 --- a/code/datums/helper_datums/construction_datum.dm +++ b/code/datums/helper_datums/construction_datum.dm @@ -61,7 +61,7 @@ else if(istype(used_atom, /obj/item/stack/cable_coil)) var/obj/item/stack/cable_coil/C = used_atom if(C.amount<4) - to_chat(user, ("There's not enough cable to finish the task.")) + to_chat(user, ("There's not enough cable to finish the task.")) return 0 else C.use(4) @@ -69,7 +69,7 @@ else if(istype(used_atom, /obj/item/stack)) var/obj/item/stack/S = used_atom if(S.amount < 5) - to_chat(user, ("There's not enough material in this stack.")) + to_chat(user, ("There's not enough material in this stack.")) return 0 else S.use(5) @@ -106,30 +106,29 @@ return proc/try_consume(mob/user as mob, atom/used_atom, amount) - if(amount>0) - // STACKS - if(istype(used_atom,/obj/item/stack)) - var/obj/item/stack/stack=used_atom - if(stack.amount < amount) - to_chat(user, "\red You don't have enough [stack]! You need at least [amount].") - return 0 - stack.use(amount) + if(amount > 0) // CABLES if(istype(used_atom,/obj/item/stack/cable_coil)) var/obj/item/stack/cable_coil/coil=used_atom - if(coil.amount < amount) - to_chat(user, "\red You don't have enough cable! You need at least [amount] coils.") + if(!coil.use(amount)) + to_chat(user, "You don't have enough cable! You need at least [amount] coils.") return 0 - coil.use(amount) // WELDER if(istype(used_atom,/obj/item/weapon/weldingtool)) var/obj/item/weapon/weldingtool/welder=used_atom if(!welder.isOn()) - to_chat(user, "\blue You tap the [src] with your unlit welder. [pick("Ding","Dong")].") + to_chat(user, "You tap the [src] with your unlit welder. [pick("Ding","Dong")].") return 0 if(!welder.remove_fuel(amount,user)) - to_chat(user, "\red You don't have enough fuel!") + to_chat(user, "You don't have enough fuel!") return 0 + // STACKS + if(istype(used_atom,/obj/item/stack)) + var/obj/item/stack/stack=used_atom + if(stack.amount < amount) + to_chat(user, "You don't have enough [stack]! You need at least [amount].") + return 0 + stack.use(amount) return 1 /datum/construction/reversible diff --git a/code/game/machinery/computer/buildandrepair.dm b/code/game/machinery/computer/buildandrepair.dm index b17a9a37aab..0c09bc5f2c5 100644 --- a/code/game/machinery/computer/buildandrepair.dm +++ b/code/game/machinery/computer/buildandrepair.dm @@ -287,7 +287,7 @@ /obj/item/weapon/circuitboard/supplycomp/attackby(obj/item/I as obj, mob/user as mob, params) if(istype(I,/obj/item/device/multitool)) - var/catastasis = src.contraband_enabled + var/catastasis = contraband_enabled var/opposite_catastasis if(catastasis) opposite_catastasis = "STANDARD" @@ -297,9 +297,9 @@ catastasis = "STANDARD" switch( alert("Current receiver spectrum is set to: [catastasis]","Multitool-Circuitboard interface","Switch to [opposite_catastasis]","Cancel") ) - //switch( alert("Current receiver spectrum is set to: " {(src.contraband_enabled) ? ("BROAD") : ("STANDARD")} , "Multitool-Circuitboard interface" , "Switch to " {(src.contraband_enabled) ? ("STANDARD") : ("BROAD")}, "Cancel") ) + //switch( alert("Current receiver spectrum is set to: " {(contraband_enabled) ? ("BROAD") : ("STANDARD")} , "Multitool-Circuitboard interface" , "Switch to " {(contraband_enabled) ? ("STANDARD") : ("BROAD")}, "Cancel") ) if("Switch to STANDARD","Switch to BROAD") - src.contraband_enabled = !src.contraband_enabled + contraband_enabled = !contraband_enabled if("Cancel") return @@ -345,97 +345,110 @@ switch(state) if(0) if(istype(P, /obj/item/weapon/wrench)) - playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) + playsound(loc, 'sound/items/Ratchet.ogg', 50, 1) if(do_after(user, 20, target = src)) - to_chat(user, "\blue You wrench the frame into place.") - src.anchored = 1 - src.state = 1 + to_chat(user, "You wrench the frame into place.") + anchored = 1 + state = 1 if(istype(P, /obj/item/weapon/weldingtool)) var/obj/item/weapon/weldingtool/WT = P if(!WT.remove_fuel(0, user)) - to_chat(user, "The welding tool must be on to complete this task.") + to_chat(user, "The welding tool must be on to complete this task.") return - playsound(src.loc, 'sound/items/Welder.ogg', 50, 1) + playsound(loc, 'sound/items/Welder.ogg', 50, 1) if(do_after(user, 20, target = src)) if(!src || !WT.isOn()) return - to_chat(user, "\blue You deconstruct the frame.") - new /obj/item/stack/sheet/metal( src.loc, 5 ) + to_chat(user, "You deconstruct the frame.") + new /obj/item/stack/sheet/metal(loc, 5) qdel(src) if(1) if(istype(P, /obj/item/weapon/wrench)) - playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) + playsound(loc, 'sound/items/Ratchet.ogg', 50, 1) if(do_after(user, 20, target = src)) - to_chat(user, "\blue You unfasten the frame.") - src.anchored = 0 - src.state = 0 + to_chat(user, "You unfasten the frame.") + anchored = 0 + state = 0 if(istype(P, /obj/item/weapon/circuitboard) && !circuit) var/obj/item/weapon/circuitboard/B = P if(B.board_type == "computer") - playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1) - to_chat(user, "\blue You place the circuit board inside the frame.") - src.icon_state = "1" - src.circuit = P + playsound(loc, 'sound/items/Deconstruct.ogg', 50, 1) + to_chat(user, "You place the circuit board inside the frame.") + icon_state = "1" + circuit = P user.drop_item() P.loc = src else - to_chat(user, "\red This frame does not accept circuit boards of this type!") + to_chat(user, "This frame does not accept circuit boards of this type!") if(istype(P, /obj/item/weapon/screwdriver) && circuit) - playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) - to_chat(user, "\blue You screw the circuit board into place.") - src.state = 2 - src.icon_state = "2" + playsound(loc, 'sound/items/Screwdriver.ogg', 50, 1) + to_chat(user, "You screw the circuit board into place.") + state = 2 + icon_state = "2" if(istype(P, /obj/item/weapon/crowbar) && circuit) - playsound(src.loc, 'sound/items/Crowbar.ogg', 50, 1) - to_chat(user, "\blue You remove the circuit board.") - src.state = 1 - src.icon_state = "0" - circuit.loc = src.loc - src.circuit = null + playsound(loc, 'sound/items/Crowbar.ogg', 50, 1) + to_chat(user, "You remove the circuit board.") + state = 1 + icon_state = "0" + circuit.loc = loc + circuit = null if(2) if(istype(P, /obj/item/weapon/screwdriver) && circuit) - playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) - to_chat(user, "\blue You unfasten the circuit board.") - src.state = 1 - src.icon_state = "1" + playsound(loc, 'sound/items/Screwdriver.ogg', 50, 1) + to_chat(user, "You unfasten the circuit board.") + state = 1 + icon_state = "1" if(istype(P, /obj/item/stack/cable_coil)) - if(P:amount >= 5) - playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1) + var/obj/item/stack/cable_coil/C = P + if(C.amount >= 5) + playsound(loc, 'sound/items/Deconstruct.ogg', 50, 1) + to_chat(user, "You start to add cables to the frame.") if(do_after(user, 20, target = src)) - if(P) - P:amount -= 5 - if(!P:amount) qdel(P) - to_chat(user, "\blue You add cables to the frame.") - src.state = 3 - src.icon_state = "3" + if(state == 2 && C.amount >= 5 && C.use(5)) + to_chat(user, "You add cables to the frame.") + state = 3 + icon_state = "3" + else + to_chat(user, "At some point during construction you lost some cable. Make sure you have five lengths before trying again.") + return + else + to_chat(user, "You need five lengths of cable to wire the frame.") + return if(3) if(istype(P, /obj/item/weapon/wirecutters)) - playsound(src.loc, 'sound/items/Wirecutter.ogg', 50, 1) - to_chat(user, "\blue You remove the cables.") - src.state = 2 - src.icon_state = "2" - var/obj/item/stack/cable_coil/A = new /obj/item/stack/cable_coil( src.loc ) + playsound(loc, 'sound/items/Wirecutter.ogg', 50, 1) + to_chat(user, "You remove the cables.") + state = 2 + icon_state = "2" + var/obj/item/stack/cable_coil/A = new /obj/item/stack/cable_coil( loc ) A.amount = 5 if(istype(P, /obj/item/stack/sheet/glass)) - if(P:amount >= 2) - playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1) + var/obj/item/stack/sheet/glass/G = P + if(G.amount >= 2) + playsound(loc, 'sound/items/Deconstruct.ogg', 50, 1) + to_chat(user, "You start to add the glass panel to the frame.") if(do_after(user, 20, target = src)) - if(P) - P:use(2) - to_chat(user, "\blue You put in the glass panel.") - src.state = 4 - src.icon_state = "4" + if(state == 3 && G.amount >= 2 && G.use(2)) + to_chat(user, "You put in the glass panel.") + state = 4 + icon_state = "4" + else + to_chat(user, "At some point during construction you lost some glass. Make sure you have two sheets before trying again.") + return + else + to_chat(user, "You need two sheets of glass for this.") + return if(4) if(istype(P, /obj/item/weapon/crowbar)) - playsound(src.loc, 'sound/items/Crowbar.ogg', 50, 1) - to_chat(user, "\blue You remove the glass panel.") - src.state = 3 - src.icon_state = "3" - new /obj/item/stack/sheet/glass( src.loc, 2 ) + playsound(loc, 'sound/items/Crowbar.ogg', 50, 1) + to_chat(user, "You remove the glass panel.") + state = 3 + icon_state = "3" + new /obj/item/stack/sheet/glass(loc, 2) if(istype(P, /obj/item/weapon/screwdriver)) - playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) - to_chat(user, "\blue You connect the monitor.") - var/B = new src.circuit.build_path ( src.loc ) + playsound(loc, 'sound/items/Screwdriver.ogg', 50, 1) + to_chat(user, "You connect the monitor.") + var/B = new circuit.build_path (loc) if(circuit.powernet) B:powernet = circuit.powernet if(circuit.id) B:id = circuit.id if(circuit.records) B:records = circuit.records @@ -456,97 +469,110 @@ switch(state) if(0) if(istype(P, /obj/item/weapon/wrench)) - playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) + playsound(loc, 'sound/items/Ratchet.ogg', 50, 1) if(do_after(user, 20, target = src)) - to_chat(user, "\blue You wrench the frame into place.") - src.anchored = 1 - src.state = 1 + to_chat(user, "You wrench the frame into place.") + anchored = 1 + state = 1 if(istype(P, /obj/item/weapon/weldingtool)) var/obj/item/weapon/weldingtool/WT = P if(!WT.remove_fuel(0, user)) - to_chat(user, "The welding tool must be on to complete this task.") + to_chat(user, "The welding tool must be on to complete this task.") return - playsound(src.loc, 'sound/items/Welder.ogg', 50, 1) + playsound(loc, 'sound/items/Welder.ogg', 50, 1) if(do_after(user, 20, target = src)) if(!src || !WT.isOn()) return - to_chat(user, "\blue You deconstruct the frame.") - new /obj/item/stack/sheet/mineral/bananium( src.loc, 5 ) + to_chat(user, "You deconstruct the frame.") + new /obj/item/stack/sheet/mineral/bananium(loc, 5) qdel(src) if(1) if(istype(P, /obj/item/weapon/wrench)) - playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) + playsound(loc, 'sound/items/Ratchet.ogg', 50, 1) if(do_after(user, 20, target = src)) - to_chat(user, "\blue You unfasten the frame.") - src.anchored = 0 - src.state = 0 + to_chat(user, "You unfasten the frame.") + anchored = 0 + state = 0 if(istype(P, /obj/item/weapon/circuitboard) && !circuit) var/obj/item/weapon/circuitboard/B = P if(B.board_type == "honkcomputer") - playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1) - to_chat(user, "\blue You place the circuit board inside the frame.") - src.icon_state = "1" - src.circuit = P + playsound(loc, 'sound/items/Deconstruct.ogg', 50, 1) + to_chat(user, "You place the circuit board inside the frame.") + icon_state = "1" + circuit = P user.drop_item() P.loc = src else - to_chat(user, "\red This frame does not accept circuit boards of this type!") + to_chat(user, "This frame does not accept circuit boards of this type!") if(istype(P, /obj/item/weapon/screwdriver) && circuit) - playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) - to_chat(user, "\blue You screw the circuit board into place.") - src.state = 2 - src.icon_state = "2" + playsound(loc, 'sound/items/Screwdriver.ogg', 50, 1) + to_chat(user, "You screw the circuit board into place.") + state = 2 + icon_state = "2" if(istype(P, /obj/item/weapon/crowbar) && circuit) - playsound(src.loc, 'sound/items/Crowbar.ogg', 50, 1) - to_chat(user, "\blue You remove the circuit board.") - src.state = 1 - src.icon_state = "0" - circuit.loc = src.loc - src.circuit = null + playsound(loc, 'sound/items/Crowbar.ogg', 50, 1) + to_chat(user, "You remove the circuit board.") + state = 1 + icon_state = "0" + circuit.loc = loc + circuit = null if(2) if(istype(P, /obj/item/weapon/screwdriver) && circuit) - playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) - to_chat(user, "\blue You unfasten the circuit board.") - src.state = 1 - src.icon_state = "1" + playsound(loc, 'sound/items/Screwdriver.ogg', 50, 1) + to_chat(user, "You unfasten the circuit board.") + state = 1 + icon_state = "1" if(istype(P, /obj/item/stack/cable_coil)) - if(P:amount >= 5) - playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1) + var/obj/item/stack/cable_coil/C = P + if(C.amount >= 5) + playsound(loc, 'sound/items/Deconstruct.ogg', 50, 1) + to_chat(user, "You start to add cables to the frame.") if(do_after(user, 20, target = src)) - if(P) - P:amount -= 5 - if(!P:amount) qdel(P) - to_chat(user, "\blue You add cables to the frame.") - src.state = 3 - src.icon_state = "3" + if(state == 2 && C.amount >= 5 && C.use(5)) + to_chat(user, "You add cables to the frame.") + state = 3 + icon_state = "3" + else + to_chat(user, "At some point during construction you lost some cable. Make sure you have five lengths before trying again.") + return + else + to_chat(user, "You need five lengths of cable to wire the frame.") + return if(3) if(istype(P, /obj/item/weapon/wirecutters)) - playsound(src.loc, 'sound/items/Wirecutter.ogg', 50, 1) - to_chat(user, "\blue You remove the cables.") - src.state = 2 - src.icon_state = "2" - var/obj/item/stack/cable_coil/A = new /obj/item/stack/cable_coil( src.loc ) + playsound(loc, 'sound/items/Wirecutter.ogg', 50, 1) + to_chat(user, "You remove the cables.") + state = 2 + icon_state = "2" + var/obj/item/stack/cable_coil/A = new /obj/item/stack/cable_coil( loc ) A.amount = 5 if(istype(P, /obj/item/stack/sheet/glass)) - if(P:amount >= 2) - playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1) + var/obj/item/stack/sheet/glass/G = P + if(G.amount >= 2) + playsound(loc, 'sound/items/Deconstruct.ogg', 50, 1) + to_chat(user, "You start to add the glass panel to the frame.") if(do_after(user, 20, target = src)) - if(P) - P:use(2) - to_chat(user, "\blue You put in the glass panel.") - src.state = 4 - src.icon_state = "4" + if(state == 3 && G.amount >= 2 && G.use(2)) + to_chat(user, "You put in the glass panel.") + state = 4 + icon_state = "4" + else + to_chat(user, "At some point during construction you lost some glass. Make sure you have two sheets before trying again.") + return + else + to_chat(user, "You need two sheets of glass for this.") + return if(4) if(istype(P, /obj/item/weapon/crowbar)) - playsound(src.loc, 'sound/items/Crowbar.ogg', 50, 1) - to_chat(user, "\blue You remove the glass panel.") - src.state = 3 - src.icon_state = "3" - new /obj/item/stack/sheet/glass( src.loc, 2 ) + playsound(loc, 'sound/items/Crowbar.ogg', 50, 1) + to_chat(user, "You remove the glass panel.") + state = 3 + icon_state = "3" + new /obj/item/stack/sheet/glass(loc, 2) if(istype(P, /obj/item/weapon/screwdriver)) - playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) - to_chat(user, "\blue You connect the monitor.") - var/B = new src.circuit.build_path ( src.loc ) + playsound(loc, 'sound/items/Screwdriver.ogg', 50, 1) + to_chat(user, "You connect the monitor.") + var/B = new circuit.build_path (loc) if(circuit.powernet) B:powernet = circuit.powernet if(circuit.id) B:id = circuit.id if(circuit.records) B:records = circuit.records diff --git a/code/game/machinery/constructable_frame.dm b/code/game/machinery/constructable_frame.dm index 2c6740ffbb3..d7384290164 100644 --- a/code/game/machinery/constructable_frame.dm +++ b/code/game/machinery/constructable_frame.dm @@ -69,21 +69,23 @@ playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1) to_chat(user, "You start to add cables to the frame.") if(do_after(user, 20, target = src)) - if(C.amount >= 5 && state == 1) - C.use(5) + if(state == 1 && C.amount >= 5 && C.use(5)) to_chat(user, "You add cables to the frame.") state = 2 icon_state = "box_1" + else + to_chat(user, "At some point during construction you lost some cable. Make sure you have five lengths before trying again.") + return else - to_chat(user, "You need five length of cable to wire the frame.") + to_chat(user, "You need five lengths of cable to wire the frame.") return else if(istype(P, /obj/item/stack/sheet/glass)) var/obj/item/stack/sheet/glass/G = P - if(G.amount<5) - to_chat(user, "\red You do not have enough glass to build a display case.") + if(G.amount < 5) + to_chat(user, "You do not have enough glass to build a display case.") return G.use(5) - to_chat(user, "\blue You add the glass to the frame.") + to_chat(user, "You add the glass to the frame.") playsound(get_turf(src), 'sound/items/Deconstruct.ogg', 50, 1) new /obj/structure/displaycase_frame(src.loc) qdel(src)