Allows nanopaste to repair machinery (#14977)

* Allows nanopaste to repair machinery

* Apply suggestions from code review

Co-authored-by: Farie82 <joepvelden@hotmail.com>

* Henks other requests

* Apply suggestions from code review

Co-authored-by: Farie82 <joepvelden@hotmail.com>

* Henks other other request

* more nanopaste requests

Co-authored-by: Farie82 <joepvelden@hotmail.com>
This commit is contained in:
Qwertytoforty
2020-11-25 23:56:58 -05:00
committed by GitHub
co-authored by Farie82
parent ddadbcf712
commit 69ef67dd79
+30
View File
@@ -126,6 +126,8 @@ Class Procs:
var/frequency = NONE
/// A reference to a `datum/radio_frequency`. Gives the machine the ability to interact with things using radio signals.
var/datum/radio_frequency/radio_connection
/// This is if the machinery is being repaired
var/being_repaired = FALSE
/*
* reimp, attempts to flicker this machinery if the behavior is supported.
@@ -476,6 +478,34 @@ Class Procs:
if(.)
power_change()
/obj/machinery/attackby(obj/item/O, mob/user, params)
if(istype(O, /obj/item/stack/nanopaste))
var/obj/item/stack/nanopaste/N = O
if(stat & BROKEN)
to_chat(user, "<span class='notice'>[src] is too damaged to be fixed with nanopaste!</span>")
return
if(obj_integrity == max_integrity)
to_chat(user, "<span class='notice'>[src] is fully intact.</span>")
return
if(being_repaired)
return
if(N.get_amount() < 1)
to_chat(user, "<span class='warning'>You don't have enough to complete this task!</span>")
return
to_chat(user, "<span class='notice'>You start applying [O] to [src].</span>")
being_repaired = TRUE
var/result = do_after(user, 3 SECONDS, target = src)
being_repaired = FALSE
if(!result)
return
if(!N.use(1))
to_chat(user, "<span class='warning'>You don't have enough to complete this task!</span>") // this is here, as we don't want to use nanopaste until you finish applying
return
obj_integrity = min(obj_integrity + 50, max_integrity)
user.visible_message("<span class='notice'>[user] applied some [O] at [src]'s damaged areas.</span>",\
"<span class='notice'>You apply some [O] at [src]'s damaged areas.</span>")
else
return ..()
/obj/machinery/proc/exchange_parts(mob/user, obj/item/storage/part_replacer/W)
var/shouldplaysound = 0
if((flags & NODECONSTRUCT))