Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
81 changes: 72 additions & 9 deletions code/modules/mining/machine_stacking.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,17 @@
src.updateUsrDialog()
return

/obj/machinery/mineral/stacking_unit_console/attackby(obj/item/W, mob/user, params)
if(default_deconstruction_screwdriver(user, "console-open", "console", W))
updateUsrDialog()
return
if(default_deconstruction_crowbar(W))
return
return ..()

/**********************Mineral stacking unit**************************/

#define INPUT 0
#define OUTPUT 1

/obj/machinery/mineral/stacking_machine
name = "stacking machine"
Expand All @@ -81,24 +89,31 @@
var/stack_amt = 50 //amount to stack before releassing
var/datum/component/remote_materials/materials
var/force_connect = FALSE
var/io = INPUT //This is used for determining whether we change the Input or Output


/obj/machinery/mineral/stacking_machine/examine(mob/user)
. = ..()
. += "<span class='notice'>Currently outputting stacks at <b>[stack_amt] sheet[(stack_amt > 1) ? "s" : ""]</b><span>"
if(panel_open)
. += "The I/O is set to change <b>[io ? "output" : "input"]</b> currently."
. += "Input is <b>[dir2text(input_dir)]</b>"
. += "Output is <b>[dir2text(output_dir)]</b>."
. += "There is a dial that can be <b>turned by hand</b> to change direction."
. += "The I/O setting can be <b>changed with a multitool</b> to change what the dial controls."
. += "There are some <b>bolts</b> to limit stack size."

/obj/machinery/mineral/stacking_machine/Initialize(mapload)
. = ..()
proximity_monitor = new(src, 1)
materials = AddComponent(/datum/component/remote_materials, "stacking", mapload, FALSE, mapload && force_connect)

/obj/machinery/mineral/stacking_machine/HasProximity(atom/movable/AM)
if(panel_open || (stat & (BROKEN|NOPOWER)))
return
if(istype(AM, /obj/item/stack/sheet) && AM.loc == get_step(src, input_dir))
process_sheet(AM)

/obj/machinery/mineral/stacking_machine/multitool_act(mob/living/user, obj/item/multitool/M)
if(istype(M))
if(istype(M.buffer, /obj/machinery/mineral/stacking_unit_console))
CONSOLE = M.buffer
CONSOLE.machine = src
to_chat(user, "<span class='notice'>You link [src] to the console in [M]'s buffer.</span>")
return TRUE

/obj/machinery/mineral/stacking_machine/proc/process_sheet(obj/item/stack/sheet/inp)
var/key = inp.merge_type
var/obj/item/stack/sheet/storage = stack_list[key]
Expand All @@ -120,3 +135,51 @@
var/obj/item/stack/sheet/out = new inp.type(null, stack_amt)
unload_mineral(out)
storage.amount -= stack_amt

/obj/machinery/mineral/stacking_machine/attackby(obj/item/W, mob/user, params)
if(default_deconstruction_screwdriver(user, "stacker-open", "stacker", W))
updateUsrDialog()
return
if(default_deconstruction_crowbar(W))
return

if(!powered())
return

if(W.tool_behaviour == TOOL_WRENCH && panel_open)
var/stsize = input(user, "How much should [src] stack to? (1-50)", "Stack size") as null|num
if(stsize)
stack_amt = CLAMP(stsize,1,50)
to_chat(user, "<span class='notice'>[src] is now set to output <b>[stack_amt] sheet[(stack_amt > 1) ? "s" : ""]</b><span>")
return

return ..()

/obj/machinery/mineral/stacking_machine/attack_hand(mob/user)
if(!panel_open)
return ..()
if(io == INPUT)
input_dir = turn(input_dir, -90)
if(input_dir == output_dir) //Input and output can't be the same or you create the immovable sheet.
input_dir = turn(input_dir, -90)
to_chat(user, "<span class='notice'>You set [src]'s input to take from the [dir2text(input_dir)].</span>")
return
else if (io == OUTPUT)
output_dir = turn(output_dir, -90)
if(input_dir == output_dir)
output_dir = turn(output_dir, -90)
to_chat(user, "<span class='notice'>You set [src]'s output to drop stacks [dir2text(output_dir)].</span>")
return
return ..()

/obj/machinery/mineral/stacking_machine/multitool_act(mob/living/user, obj/item/multitool/M)
if(istype(M))
if(istype(M.buffer, /obj/machinery/mineral/stacking_unit_console) && !panel_open)
CONSOLE = M.buffer
CONSOLE.machine = src
to_chat(user, "<span class='notice'>You link [src] to the console in [M]'s buffer.</span>")
return TRUE
if(panel_open)
io = !io
to_chat(user, "<span class='notice'>You set the I/O to change [io ? "output" : "input"].</span>")
return TRUE
Binary file modified icons/obj/machines/mining_machines.dmi
Binary file not shown.