mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-22 04:22:39 +01:00
Cable Layer Update (#10848)
This commit is contained in:
@@ -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, "<span class='warning'>\The [src] doesn't have any cable loaded.</span>")
|
||||
/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, "<span class='warning'>\The [src]'s cable reel is full.</span>")
|
||||
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, "<span class='warning'>There's no more cable on the reel.</span>")
|
||||
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
|
||||
@@ -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."
|
||||
Reference in New Issue
Block a user