diff --git a/baystation12.dme b/baystation12.dme
index 98342a0dea2..800d7cb44a7 100644
--- a/baystation12.dme
+++ b/baystation12.dme
@@ -167,6 +167,7 @@
#include "code\datums\wires\airlock.dm"
#include "code\datums\wires\alarm.dm"
#include "code\datums\wires\apc.dm"
+#include "code\datums\wires\autolathe.dm"
#include "code\datums\wires\camera.dm"
#include "code\datums\wires\robot.dm"
#include "code\datums\wires\smartfridge.dm"
diff --git a/code/datums/wires/autolathe.dm b/code/datums/wires/autolathe.dm
new file mode 100644
index 00000000000..1dd4132e481
--- /dev/null
+++ b/code/datums/wires/autolathe.dm
@@ -0,0 +1,60 @@
+/datum/wires/autolathe
+
+ holder_type = /obj/machinery/autolathe
+ wire_count = 6
+
+var/const/AUTOLATHE_HACK_WIRE = 1
+var/const/AUTOLATHE_SHOCK_WIRE = 2
+var/const/AUTOLATHE_DISABLE_WIRE = 4
+
+/datum/wires/autolathe/GetInteractWindow()
+ var/obj/machinery/autolathe/A = holder
+ . += ..()
+ . += "
The red light is [A.disabled ? "off" : "on"]."
+ . += "
The green light is [A.shocked ? "off" : "on"]."
+ . += "
The blue light is [A.hacked ? "off" : "on"].
"
+
+/datum/wires/autolathe/CanUse()
+ var/obj/machinery/autolathe/A = holder
+ if(A.panel_open)
+ return 1
+ return 0
+
+/datum/wires/autolathe/Interact(var/mob/living/user)
+ if(CanUse(user))
+ var/obj/machinery/autolathe/V = holder
+ V.attack_hand(user)
+
+/datum/wires/autolathe/UpdateCut(index, mended)
+ var/obj/machinery/autolathe/A = holder
+ switch(index)
+ if(AUTOLATHE_HACK_WIRE)
+ A.hacked = !mended
+ if(AUTOLATHE_SHOCK_WIRE)
+ A.shocked = !mended
+ if(AUTOLATHE_DISABLE_WIRE)
+ A.disabled = !mended
+
+/datum/wires/autolathe/UpdatePulsed(index)
+ if(IsIndexCut(index))
+ return
+ var/obj/machinery/autolathe/A = holder
+ switch(index)
+ if(AUTOLATHE_HACK_WIRE)
+ A.hacked = !A.hacked
+ spawn(50)
+ if(A && !IsIndexCut(index))
+ A.hacked = 0
+ Interact(usr)
+ if(AUTOLATHE_SHOCK_WIRE)
+ A.shocked = !A.shocked
+ spawn(50)
+ if(A && !IsIndexCut(index))
+ A.shocked = 0
+ Interact(usr)
+ if(AUTOLATHE_DISABLE_WIRE)
+ A.disabled = !A.disabled
+ spawn(50)
+ if(A && !IsIndexCut(index))
+ A.disabled = 0
+ Interact(usr)
diff --git a/code/game/machinery/autolathe.dm b/code/game/machinery/autolathe.dm
index 6752128279b..6f27a86f949 100644
--- a/code/game/machinery/autolathe.dm
+++ b/code/game/machinery/autolathe.dm
@@ -12,16 +12,13 @@
var/list/storage_capacity = list("metal" = 0, "glass" = 0)
var/show_category = "All"
- var/opened = 0
+ var/panel_open = 0
var/hacked = 0
var/disabled = 0
var/shocked = 0
var/busy = 0
- var/list/wires = list()
- var/hack_wire
- var/disable_wire
- var/shock_wire
+ var/datum/wires/autolathe/wires = null
/obj/machinery/autolathe/interact(mob/user as mob)
@@ -33,69 +30,64 @@
var/dat = "
Autolathe Control Panel
"
- dat += ""
- var/material_top = ""
- var/material_bottom = "
"
+ if(!panel_open)
+ dat += ""
+ var/material_top = ""
+ var/material_bottom = "
"
- for(var/material in stored_material)
- material_top += "| [material] | "
- material_bottom += "[stored_material[material]]/[storage_capacity[material]] | "
+ for(var/material in stored_material)
+ material_top += "[material] | "
+ material_bottom += "[stored_material[material]]/[storage_capacity[material]] | "
- dat += "[material_top]
[material_bottom]
"
- dat += "Printable Designs
"
+ dat += "[material_top][material_bottom]
"
+ dat += "Printable Designs
"
- var/index = 0
- for(var/datum/autolathe/recipe/R in autolathe_recipes)
- index++
- if(R.hidden && !hacked || (show_category != "All" && show_category != R.category))
- continue
+ var/index = 0
+ for(var/datum/autolathe/recipe/R in autolathe_recipes)
+ index++
+ if(R.hidden && !hacked || (show_category != "All" && show_category != R.category))
+ continue
- var/can_make = 1
- var/material_string = ""
- var/multiplier_string = ""
- var/max_sheets
+ var/can_make = 1
+ var/material_string = ""
+ var/multiplier_string = ""
+ var/max_sheets
- var/comma
- if(!R.resources || !R.resources.len)
- material_string = "No resources required."
- else
+ var/comma
+ if(!R.resources || !R.resources.len)
+ material_string = "No resources required."
+ else
- //Make sure it's buildable and list requires resources.
- for(var/material in R.resources)
- var/sheets = round(stored_material[material]/R.resources[material])
- if(isnull(max_sheets) || max_sheets > sheets)
- max_sheets = sheets
+ //Make sure it's buildable and list requires resources.
+ for(var/material in R.resources)
+ var/sheets = round(stored_material[material]/R.resources[material])
+ if(isnull(max_sheets) || max_sheets > sheets)
+ max_sheets = sheets
- if(!isnull(stored_material[material]) && stored_material[material] < R.resources[material])
- can_make = 0
- if(!comma)
- comma = 1
- else
- material_string += ", "
- material_string += "[R.resources[material]] [material]"
- material_string += ".
"
+ if(!isnull(stored_material[material]) && stored_material[material] < R.resources[material])
+ can_make = 0
+ if(!comma)
+ comma = 1
+ else
+ material_string += ", "
+ material_string += "[R.resources[material]] [material]"
+ material_string += ".
"
- //Build list of multipliers for sheets.
- if(R.is_stack)
- if(max_sheets && max_sheets > 0)
- multiplier_string += "
"
- for(var/i = 5;i\[x[i]\]"
- multiplier_string += "\[x[max_sheets]\]"
+ //Build list of multipliers for sheets.
+ if(R.is_stack)
+ if(max_sheets && max_sheets > 0)
+ multiplier_string += "
"
+ for(var/i = 5;i\[x[i]\]"
+ multiplier_string += "\[x[max_sheets]\]"
- dat += "| [R.hidden ? "*" : ""][can_make ? "" : ""][R.name][can_make ? "" : ""][R.hidden ? "*" : ""][multiplier_string] | [material_string] |
"
-
- dat += "
"
+ dat += "
| [R.hidden ? "*" : ""][can_make ? "" : ""][R.name][can_make ? "" : ""][R.hidden ? "*" : ""][multiplier_string] | [material_string] |
"
+ dat += "
"
//Hacking.
- if(opened)
+ else
dat += "Maintenance Panel
"
- for(var/wire in wires)
- dat += "[wire] Wire: [wires[wire] ? "Mend" : "Cut"] Pulse
"
- dat += "
"
- dat += "The red light is [disabled ? "off" : "on"].
"
- dat += "The green light is [shocked ? "off" : "on"].
"
- dat += "The blue light is [hacked ? "off" : "on"].
"
+ dat += wires.GetInteractWindow()
dat += "
"
@@ -112,13 +104,13 @@
return
if(istype(O, /obj/item/weapon/screwdriver))
- opened = !opened
- icon_state = (opened ? "autolathe_t": "autolathe")
- user << "You [opened ? "open" : "close"] the maintenance hatch of [src]."
+ panel_open = !panel_open
+ icon_state = (panel_open ? "autolathe_t": "autolathe")
+ user << "You [panel_open ? "open" : "close"] the maintenance hatch of [src]."
updateUsrDialog()
return
- if (opened)
+ if (panel_open)
//Don't eat multitools or wirecutters used on an open lathe.
if(istype(O, /obj/item/device/multitool) || istype(O, /obj/item/weapon/wirecutters))
attack_hand(user)
@@ -253,65 +245,13 @@
var/obj/item/stack/S = I
S.amount = multiplier
- if(href_list["act"])
-
- var/temp_wire = href_list["wire"]
- if(href_list["act"] == "pulse")
-
- if (!istype(usr.get_active_hand(), /obj/item/device/multitool))
- usr << "You need a multitool!"
- return
-
- if(wires[temp_wire])
- usr << "You can't pulse a cut wire."
- return
-
- if(hack_wire == temp_wire)
- hacked = !hacked
-
- spawn(100)
- hacked = !hacked
-
- if(disable_wire == temp_wire)
- disabled = !disabled
- shock(usr,50)
-
- spawn(100)
- disabled = !disabled
-
- if(shock_wire == temp_wire)
- shocked = !shocked
- shock(usr,50)
-
- spawn(100)
- shocked = !shocked
-
- else if(href_list["act"] == "wire")
-
- if (!istype(usr.get_active_hand(), /obj/item/weapon/wirecutters))
- usr << "You need wirecutters!"
- return
-
- wires[temp_wire] = !wires[temp_wire]
-
- if(hack_wire == temp_wire)
- hacked = !hacked
-
- if(disable_wire == temp_wire)
- disabled = !disabled
- shock(usr,50)
-
- if(shock_wire == temp_wire)
- shocked = !shocked
- shock(usr,50)
-
updateUsrDialog()
/obj/machinery/autolathe/New()
..()
-
+ wires = new(src)
//Create global autolathe recipe list if it hasn't been made already.
if(isnull(autolathe_recipes))
autolathe_recipes = list()
@@ -339,28 +279,6 @@
component_parts += new /obj/item/weapon/stock_parts/console_screen(src)
RefreshParts()
- //Init wires.
- wires = list(
- "Light Red" = 0,
- "Dark Red" = 0,
- "Blue" = 0,
- "Green" = 0,
- "Yellow" = 0,
- "Black" = 0,
- "White" = 0,
- "Gray" = 0,
- "Orange" = 0,
- "Pink" = 0
- )
-
- //Randomize wires.
- var/list/w = list("Light Red","Dark Red","Blue","Green","Yellow","Black","White","Gray","Orange","Pink")
- hack_wire = pick(w)
- w -= hack_wire
- shock_wire = pick(w)
- w -= shock_wire
- disable_wire = pick(w)
- w -= disable_wire
//Updates overall lathe storage size.
/obj/machinery/autolathe/RefreshParts()