Skip to content

Commit

Permalink
Code Readability - Pipe Dispenser (#18169)
Browse files Browse the repository at this point in the history
* pipe_dispenser

* prrefer wrench_act for wrench use

* Use User, Not Usr

Co-authored-by: Sirryan2002 <80364400+Sirryan2002@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Charlie <69320440+hal9000PR@users.noreply.github.com>

Co-authored-by: Sirryan2002 <80364400+Sirryan2002@users.noreply.github.com>
Co-authored-by: Charlie <69320440+hal9000PR@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 3, 2022
1 parent da94f63 commit 3613019
Showing 1 changed file with 31 additions and 30 deletions.
61 changes: 31 additions & 30 deletions code/game/machinery/pipe/pipe_dispenser.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
icon_state = "pipe_d"
density = TRUE
anchored = TRUE
var/unwrenched = 0
var/unwrenched = FALSE
var/wait = 0

/obj/machinery/pipedispenser/detailed_examine()
Expand Down Expand Up @@ -99,41 +99,42 @@
new /obj/item/pipe_gsensor(loc)
return TRUE

/obj/machinery/pipedispenser/attackby(obj/item/W as obj, mob/user as mob, params)
/obj/machinery/pipedispenser/wrench_act(mob/user, obj/item/I)
. = TRUE
if(unwrenched)
playsound(loc, I.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to fasten \the [src] to the floor...</span>")
if(do_after(user, 2 SECONDS * I.toolspeed, target = src))
user.visible_message( \
"[user] fastens \the [src].", \
"<span class='notice'>You have fastened \the [src]. Now it can dispense pipes.</span>", \
"You hear ratchet.")
anchored = TRUE
stat &= ~MAINT
unwrenched = FALSE
power_change()
else
playsound(loc, I.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to unfasten \the [src] from the floor...</span>")
if(do_after(user, 4 SECONDS * I.toolspeed, target = src))
user.visible_message( \
"[user] unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src]. Now it can be pulled somewhere else.</span>", \
"You hear ratchet.")
anchored = FALSE
stat |= MAINT
unwrenched = TRUE
if(user.machine == src)
user << browse(null, "window=pipedispenser")

/obj/machinery/pipedispenser/attackby(obj/item/W, mob/user, params)
add_fingerprint(usr)
if(istype(W, /obj/item/pipe) || istype(W, /obj/item/pipe_meter) || istype(W, /obj/item/pipe_gsensor))
to_chat(usr, "<span class='notice'>You put [W] back to [src].</span>")
user.drop_item()
qdel(W)
return
else if(istype(W, /obj/item/wrench))
if(unwrenched==0)
playsound(loc, W.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to unfasten \the [src] from the floor...</span>")
if(do_after(user, 40 * W.toolspeed, target = src))
user.visible_message( \
"[user] unfastens \the [src].", \
"<span class='notice'>You have unfastened \the [src]. Now it can be pulled somewhere else.</span>", \
"You hear ratchet.")
anchored = 0
stat |= MAINT
unwrenched = 1
if(usr.machine==src)
usr << browse(null, "window=pipedispenser")
else /*if(unwrenched==1)*/
playsound(loc, W.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to fasten \the [src] to the floor...</span>")
if(do_after(user, 20 * W.toolspeed, target = src))
user.visible_message( \
"[user] fastens \the [src].", \
"<span class='notice'>You have fastened \the [src]. Now it can dispense pipes.</span>", \
"You hear ratchet.")
anchored = 1
stat &= ~MAINT
unwrenched = 0
power_change()
else
return ..()
return ..()


/obj/machinery/pipedispenser/disposal
Expand Down

0 comments on commit 3613019

Please sign in to comment.