Added ability to rename devices with a pen, sanity checks, reduced code spaghetti

This commit is contained in:
Arkatos1
2019-04-21 19:27:54 +02:00
parent 3f6b8478ff
commit b00c44d701
4 changed files with 100 additions and 36 deletions
@@ -36,13 +36,11 @@ Thus, the two variables affect pump operation are set in New():
return
if(!ishuman(usr) && !issilicon(usr))
return
on = !on
update_icon()
toggle()
return ..()
/obj/machinery/atmospherics/binary/pump/AICtrlClick()
on = !on
update_icon()
toggle()
return ..()
/obj/machinery/atmospherics/binary/pump/AltClick(mob/living/user)
@@ -53,15 +51,23 @@ Thus, the two variables affect pump operation are set in New():
return
if(!ishuman(usr) && !issilicon(usr))
return
target_pressure = MAX_OUTPUT_PRESSURE
update_icon()
set_max()
return ..()
/obj/machinery/atmospherics/binary/pump/AIAltClick()
target_pressure = MAX_OUTPUT_PRESSURE
update_icon()
set_max()
return ..()
/obj/machinery/atmospherics/binary/pump/proc/toggle()
if(powered())
on = !on
update_icon()
/obj/machinery/atmospherics/binary/pump/proc/set_max()
if(powered())
target_pressure = MAX_OUTPUT_PRESSURE
update_icon()
/obj/machinery/atmospherics/binary/pump/Destroy()
if(radio_controller)
radio_controller.remove_object(src, frequency)
@@ -237,7 +243,15 @@ Thus, the two variables affect pump operation are set in New():
update_icon()
/obj/machinery/atmospherics/binary/pump/attackby(obj/item/W, mob/user, params)
if(!istype(W, /obj/item/wrench))
if(istype(W, /obj/item/pen))
var/t = copytext(stripped_input(user, "Enter the name for the pump.", "Rename", name), 1, MAX_NAME_LEN)
if(!t)
return
if(!in_range(src, usr) && loc != usr)
return
name = t
return
else if(!istype(W, /obj/item/wrench))
return ..()
if(!(stat & NOPOWER) && on)
to_chat(user, "<span class='alert'>You cannot unwrench this [src], turn it off first.</span>")
@@ -36,13 +36,11 @@ Thus, the two variables affect pump operation are set in New():
return
if(!ishuman(usr) && !issilicon(usr))
return
on = !on
update_icon()
toggle()
return ..()
/obj/machinery/atmospherics/binary/volume_pump/AICtrlClick()
on = !on
update_icon()
toggle()
return ..()
/obj/machinery/atmospherics/binary/volume_pump/AltClick(mob/living/user)
@@ -53,15 +51,23 @@ Thus, the two variables affect pump operation are set in New():
return
if(!ishuman(usr) && !issilicon(usr))
return
transfer_rate = MAX_TRANSFER_RATE
update_icon()
set_max()
return ..()
/obj/machinery/atmospherics/binary/volume_pump/AIAltClick()
transfer_rate = MAX_TRANSFER_RATE
update_icon()
set_max()
return ..()
/obj/machinery/atmospherics/binary/volume_pump/proc/toggle()
if(powered())
on = !on
update_icon()
/obj/machinery/atmospherics/binary/volume_pump/proc/set_max()
if(powered())
transfer_rate = MAX_TRANSFER_RATE
update_icon()
/obj/machinery/atmospherics/binary/volume_pump/Destroy()
if(radio_controller)
radio_controller.remove_object(src, frequency)
@@ -233,7 +239,15 @@ Thus, the two variables affect pump operation are set in New():
update_icon()
/obj/machinery/atmospherics/binary/volume_pump/attackby(obj/item/W, mob/user, params)
if(!istype(W, /obj/item/wrench))
if(istype(W, /obj/item/pen))
var/t = copytext(stripped_input(user, "Enter the name for the volume pump.", "Rename", name), 1, MAX_NAME_LEN)
if(!t)
return
if(!in_range(src, usr) && loc != usr)
return
name = t
return
else if(!istype(W, /obj/item/wrench))
return ..()
if(!(stat & NOPOWER) && on)
to_chat(user, "<span class='alert'>You cannot unwrench this [src], turn it off first.</span>")
@@ -30,13 +30,11 @@ Filter types:
return
if(!ishuman(usr) && !issilicon(usr))
return
on = !on
update_icon()
toggle()
return ..()
/obj/machinery/atmospherics/trinary/filter/AICtrlClick()
on = !on
update_icon()
toggle()
return ..()
/obj/machinery/atmospherics/trinary/filter/AltClick(mob/living/user)
@@ -47,15 +45,23 @@ Filter types:
return
if(!ishuman(usr) && !issilicon(usr))
return
target_pressure = MAX_OUTPUT_PRESSURE
update_icon()
set_max()
return ..()
/obj/machinery/atmospherics/trinary/filter/AIAltClick()
target_pressure = MAX_OUTPUT_PRESSURE
update_icon()
set_max()
return ..()
/obj/machinery/atmospherics/trinary/filter/proc/toggle()
if(powered())
on = !on
update_icon()
/obj/machinery/atmospherics/trinary/filter/proc/set_max()
if(powered())
target_pressure = MAX_OUTPUT_PRESSURE
update_icon()
/obj/machinery/atmospherics/trinary/filter/Destroy()
if(radio_controller)
radio_controller.remove_object(src, frequency)
@@ -244,4 +250,16 @@ Filter types:
. = TRUE
update_icon()
SSnanoui.update_uis(src)
SSnanoui.update_uis(src)
/obj/machinery/atmospherics/trinary/filter/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/pen))
var/t = copytext(stripped_input(user, "Enter the name for the filter.", "Rename", name), 1, MAX_NAME_LEN)
if(!t)
return
if(!in_range(src, usr) && loc != usr)
return
name = t
return
else
return ..()
@@ -20,13 +20,11 @@
return
if(!ishuman(usr) && !issilicon(usr))
return
on = !on
update_icon()
toggle()
return ..()
/obj/machinery/atmospherics/trinary/mixer/AICtrlClick()
on = !on
update_icon()
toggle()
return ..()
/obj/machinery/atmospherics/trinary/mixer/AltClick(mob/living/user)
@@ -37,19 +35,27 @@
return
if(!ishuman(usr) && !issilicon(usr))
return
target_pressure = MAX_OUTPUT_PRESSURE
update_icon()
set_max()
return ..()
/obj/machinery/atmospherics/trinary/mixer/AIAltClick()
target_pressure = MAX_OUTPUT_PRESSURE
update_icon()
set_max()
return ..()
/obj/machinery/atmospherics/trinary/mixer/flipped
icon_state = "mmap"
flipped = 1
/obj/machinery/atmospherics/trinary/mixer/proc/toggle()
if(powered())
on = !on
update_icon()
/obj/machinery/atmospherics/trinary/mixer/proc/set_max()
if(powered())
target_pressure = MAX_OUTPUT_PRESSURE
update_icon()
/obj/machinery/atmospherics/trinary/mixer/update_icon(safety = 0)
if(flipped)
icon_state = "m"
@@ -210,4 +216,16 @@
. = TRUE
update_icon()
SSnanoui.update_uis(src)
SSnanoui.update_uis(src)
/obj/machinery/atmospherics/trinary/mixer/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/pen))
var/t = copytext(stripped_input(user, "Enter the name for the mixer.", "Rename", name), 1, MAX_NAME_LEN)
if(!t)
return
if(!in_range(src, usr) && loc != usr)
return
name = t
return
else
return ..()