From f42318d33a119eecf287df02e419084646e83ca2 Mon Sep 17 00:00:00 2001 From: Geeves Date: Thu, 31 Dec 2020 21:41:41 +0200 Subject: [PATCH] Cable Layer Update (#10848) --- code/game/machinery/CableLayer.dm | 78 +++++++++---------- html/changelogs/geeves-cable_layer_update.yml | 8 ++ 2 files changed, 47 insertions(+), 39 deletions(-) create mode 100644 html/changelogs/geeves-cable_layer_update.yml diff --git a/code/game/machinery/CableLayer.dm b/code/game/machinery/CableLayer.dm index 112b469beae..5016f871fa6 100644 --- a/code/game/machinery/CableLayer.dm +++ b/code/game/machinery/CableLayer.dm @@ -12,42 +12,49 @@ /obj/machinery/cablelayer/Initialize() . = ..() cable = new(src) - cable.amount = 100 + cable.amount = max_cable /obj/machinery/cablelayer/Move(new_turf,M_Dir) ..() - layCable(new_turf,M_Dir) + if(on) + layCable(new_turf,M_Dir) -/obj/machinery/cablelayer/attack_hand(mob/user as mob) - if(!cable&&!on) - to_chat(user, "\The [src] doesn't have any cable loaded.") +/obj/machinery/cablelayer/attack_hand(mob/user) + if(!cable && !on) + to_chat(user, SPAN_WARNING("\The [src] doesn't have any cable loaded.")) return - on=!on - user.visible_message("\The [user] [!on?"dea":"a"]ctivates \the [src].", "You switch [src] [on? "on" : "off"]") + on = !on + user.visible_message("\The [user] [!on ? "de" : ""]activates \the [src].", SPAN_NOTICE("You switch \the [src] [on ? "on" : "off"].")) return -/obj/machinery/cablelayer/attackby(var/obj/item/O as obj, var/mob/user as mob) +/obj/machinery/cablelayer/attackby(var/obj/item/O, var/mob/user) if(O.iscoil()) - var/result = load_cable(O) if(!result) - to_chat(user, "\The [src]'s cable reel is full.") + to_chat(user, SPAN_WARNING("\The [src]'s cable reel is full.")) else - to_chat(user, "You load [result] lengths of cable into [src].") + to_chat(user, SPAN_NOTICE("You load [result] lengths of cable into \the [src].")) return if(O.iswirecutter()) if(cable && cable.amount) - var/m = round(input(usr,"Please specify the length of cable to cut","Cut cable",min(cable.amount,30)) as num, 1) + var/m = round(input(usr,"Please specify the length of cable to cut.", "Cut Cable",min(cable.amount,30)) as num, 1) m = min(m, cable.amount) m = min(m, 30) if(m) playsound(loc, 'sound/items/wirecutter.ogg', 50, 1) - use_cable(m) - var/obj/item/stack/cable_coil/CC = new (get_turf(src)) - CC.amount = m + var/cable_color = use_cable(m) + var/obj/item/stack/cable_coil/CC = new(get_turf(src), m, cable_color) + user.put_in_hands(CC) else - to_chat(usr, "There's no more cable on the reel.") + to_chat(user, SPAN_WARNING("There's no more cable on the reel.")) + return + + if(O.ismultitool()) + if(!cable) + to_chat(user, SPAN_WARNING("\The [src] doesn't have any cable loaded!")) + return + cable.attackby(O, user) /obj/machinery/cablelayer/examine(mob/user) ..() @@ -60,49 +67,43 @@ if(to_load) to_load = min(CC.amount, to_load) if(!cable) - cable = new(src) - cable.amount = 0 - cable.amount += to_load + cable = new(src, 0, CC.color) + cable.amount = to_load CC.use(to_load) return to_load else - return 0 - return + return FALSE /obj/machinery/cablelayer/proc/use_cable(amount) - if(!cable || cable.amount<1) - visible_message("A red light flashes on \the [src].") + if(!cable || cable.amount < 1) + on = FALSE + reset() + playsound(loc, 'sound/machines/buzz-sigh.ogg', 50, TRUE) + visible_message(SPAN_WARNING("A red light flashes on \the [src].")) return + var/cable_color = cable.color cable.use(amount) if(QDELETED(cable)) cable = null - return 1 + return cable_color /obj/machinery/cablelayer/proc/reset() last_piece = null -/obj/machinery/cablelayer/proc/dismantleFloor(var/turf/new_turf) - if(istype(new_turf, /turf/simulated/floor)) - var/turf/simulated/floor/T = new_turf - if(!T.is_plating()) - T.make_plating(!(T.broken || T.burnt)) - return new_turf.is_plating() - /obj/machinery/cablelayer/proc/layCable(var/turf/new_turf,var/M_Dir) - if(!on) + if(!istype(new_turf)) return reset() - else - dismantleFloor(new_turf) - if(!istype(new_turf) || !dismantleFloor(new_turf)) + if(!new_turf.is_plating()) return reset() var/fdirn = turn(M_Dir,180) for(var/obj/structure/cable/LC in new_turf) // check to make sure there's not a cable there already if(LC.d1 == fdirn || LC.d2 == fdirn) return reset() - if(!use_cable(1)) + var/cable_color = use_cable(1) + if(!cable_color) return reset() var/obj/structure/cable/NC = new(new_turf) - NC.cableColor("red") + NC.cableColor(cable_color) NC.d1 = 0 NC.d2 = fdirn NC.update_icon() @@ -119,6 +120,5 @@ PN.add_cable(NC) NC.mergeConnectedNetworks(NC.d2) - //NC.mergeConnectedNetworksOnTurf() last_piece = NC - return 1 + return TRUE \ No newline at end of file diff --git a/html/changelogs/geeves-cable_layer_update.yml b/html/changelogs/geeves-cable_layer_update.yml new file mode 100644 index 00000000000..c61d785b539 --- /dev/null +++ b/html/changelogs/geeves-cable_layer_update.yml @@ -0,0 +1,8 @@ +author: Geeves + +delete-after: True + +changes: + - rscadd: "Cable layer code has been updated to be a little bit more sane. It will no longer tear up floor tiles to turn it into plating." + - rscadd: "Cable layers can now use different colours of cable. Use a multitool on it to change the colour." + - rscadd: "The cable layer now plays a sound when it runs out of cable."