Files
Bubberstation/code/modules/plumbing/plumbers/splitters.dm
SkyratBot 98568e191a [MIRROR] Enforce preserving parent proc return values across ui_act call stacks (#999)
* Enforce preserving parent proc return values across ui_act call stacks (#53964)

All ui_act procs should call parent by default. All procs should preserve the value of the parent proc when it's TRUTHY and pass it down the call stack. No UI should be interactible when its flags or state indicate it should not be, except when explicity overriden by child procs intentionally disregarding parent return values to achieve a specific goal.

* Enforce preserving parent proc return values across ui_act call stacks

Co-authored-by: Timberpoes <silent_insomnia_pp@hotmail.co.uk>
2020-09-26 17:17:59 +02:00

52 lines
1.7 KiB
Plaintext

///it splits the reagents however you want. So you can "every 60 units, 45 goes left and 15 goes straight". The side direction is EAST, you can change this in the component
/obj/machinery/plumbing/splitter
name = "Chemical Splitter"
desc = "A chemical splitter for smart chemical factorization. Waits till a set of conditions is met and then stops all input and splits the buffer evenly or other in two ducts."
icon_state = "splitter"
buffer = 100
density = FALSE
///constantly switches between TRUE and FALSE. TRUE means the batch tick goes straight, FALSE means the next batch goes in the side duct.
var/turn_straight = TRUE
///how much we must transfer straight. note input can be as high as 10 reagents per process, usually
var/transfer_straight = 5
///how much we must transfer to the side
var/transfer_side = 5
//the maximum you can set the transfer to
var/max_transfer = 9
/obj/machinery/plumbing/splitter/Initialize(mapload, bolt)
. = ..()
AddComponent(/datum/component/plumbing/splitter, bolt)
/obj/machinery/plumbing/splitter/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "ChemSplitter", name)
ui.open()
/obj/machinery/plumbing/splitter/ui_data(mob/user)
var/list/data = list()
data["straight"] = transfer_straight
data["side"] = transfer_side
data["max_transfer"] = max_transfer
return data
/obj/machinery/plumbing/splitter/ui_act(action, params)
. = ..()
if(.)
return
. = TRUE
switch(action)
if("set_amount")
var/direction = params["target"]
var/value = clamp(text2num(params["amount"]), 1, max_transfer)
switch(direction)
if("straight")
transfer_straight = value
if("side")
transfer_side = value
else
return FALSE