mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-19 20:15:47 +01:00
21b4095dfd
Upstream 04/17/2026 fixes https://github.com/Bubberstation/Bubberstation/issues/5549 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com> Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com> Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com> Co-authored-by: rageguy505 <54517726+rageguy505@users.noreply.github.com> Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> Co-authored-by: Aliceee2ch <160794176+Aliceee2ch@users.noreply.github.com> Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com> Co-authored-by: Tsar-Salat <62388554+Tsar-Salat@users.noreply.github.com> Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com> Co-authored-by: Maxipat <108554989+Maxipat112@users.noreply.github.com> Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: SimplyLogan <47579821+loganuk@users.noreply.github.com> Co-authored-by: loganuk <fakeemail123@aol.com> Co-authored-by: Leland Kemble <70413276+lelandkemble@users.noreply.github.com> Co-authored-by: FalloutFalcon <86381784+FalloutFalcon@users.noreply.github.com> Co-authored-by: Roxy <75404941+TealSeer@users.noreply.github.com> Co-authored-by: Lucy <lucy@absolucy.moe> Co-authored-by: siliconOpossum <138069572+siliconOpossum@users.noreply.github.com> Co-authored-by: Isratosh <Isratosh@hotmail.com> Co-authored-by: TheRyeGuyWhoWillNowDie <70169560+TheRyeGuyWhoWillNowDie@users.noreply.github.com> Co-authored-by: Neocloudy <88008002+Neocloudy@users.noreply.github.com> Co-authored-by: Alexander V. <volas@ya.ru> Co-authored-by: ElGitificador <168473461+ElGitificador@users.noreply.github.com> Co-authored-by: Twaticus <46540570+Twaticus@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> Co-authored-by: Cameron Lennox <killer65311@gmail.com> Co-authored-by: Tim <timothymtorres@gmail.com> Co-authored-by: Iamgoofball <iamgoofball@gmail.com> Co-authored-by: Layzu666 <121319428+Layzu666@users.noreply.github.com> Co-authored-by: Arturlang <24881678+Arturlang@users.noreply.github.com> Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com> Co-authored-by: mrmanlikesbt <99309552+mrmanlikesbt@users.noreply.github.com> Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Co-authored-by: John F. Kennedy <54908920+MacaroniCritter@users.noreply.github.com> Co-authored-by: Cursor <102828457+theselfish@users.noreply.github.com> Co-authored-by: Josh <josh.adam.powell@gmail.com> Co-authored-by: Josh Powell <josh.powell@softwire.com> Co-authored-by: Yobrocharlie <Charliemiller5617@gmail.com> Co-authored-by: Hardly3D <66234359+Hardly3D@users.noreply.github.com> Co-authored-by: shayoki <96078776+shayoki@users.noreply.github.com> Co-authored-by: LT3 <83487515+lessthnthree@users.noreply.github.com>
201 lines
6.4 KiB
Plaintext
201 lines
6.4 KiB
Plaintext
///the minimum size of a pill or patch
|
|
#define MIN_VOLUME 1 // BUBBER EDIT CHANGE - Original: 5
|
|
///max amount of pills allowed on our tile before we start storing them instead
|
|
#define MAX_FLOOR_PRODUCTS 4 // BUBBER EDIT CHANGE - Original: 10
|
|
|
|
///We take a constant input of reagents, and produce a pill once a set volume is reached
|
|
/obj/machinery/plumbing/pill_press
|
|
name = "chemical press"
|
|
desc = "A press that makes pills, patches and bottles."
|
|
icon_state = "pill_press"
|
|
|
|
/// selected size of the product
|
|
var/current_volume = 10
|
|
/// maximum printable volume of the product
|
|
var/max_volume = 100 // BUBBER EDIT CHANGE - Original: 50
|
|
buffer = 100 // BUBBER EDIT CHANGE - you need to have a buffer now or it won't fill the 100u bottles, since the default buffer is 50u
|
|
/// prefix for the product name
|
|
var/product_name = "factory"
|
|
/// Selected duration of produced pills, if they're selected
|
|
var/pill_duration = 3
|
|
/// All packaging types wrapped up in 1 big list
|
|
var/static/list/packaging_types = null
|
|
///The type of packaging to use
|
|
var/obj/item/reagent_containers/packaging_type
|
|
///Category of packaging
|
|
var/packaging_category
|
|
|
|
/obj/machinery/plumbing/pill_press/Initialize(mapload, layer)
|
|
. = ..()
|
|
|
|
if(!packaging_types)
|
|
var/datum/asset/spritesheet_batched/assets = get_asset_datum(/datum/asset/spritesheet_batched/chemmaster)
|
|
|
|
var/list/types = list(
|
|
CAT_PILLS = GLOB.reagent_containers[CAT_PILLS],
|
|
CAT_PATCHES = GLOB.reagent_containers[CAT_PATCHES],
|
|
CAT_HYPOS = GLOB.reagent_containers[CAT_HYPOS], // SKYRAT EDIT ADDITION - Hypovials
|
|
CAT_PEN_INJECTORS = GLOB.reagent_containers[CAT_PEN_INJECTORS], // BUBBER EDIT pen_medipens
|
|
CAT_MEDBOTTLES = GLOB.reagent_containers[CAT_MEDBOTTLES], // BUBBER EDIT - CAT_MEDBOTTLES
|
|
)
|
|
|
|
packaging_types = list()
|
|
for(var/category in types)
|
|
var/list/packages = types[category]
|
|
|
|
var/list/category_item = list("cat_name" = category)
|
|
for(var/obj/item/reagent_containers/container as anything in packages)
|
|
var/list/package_item = list(
|
|
"class_name" = assets.icon_class_name(sanitize_css_class_name("[container]")),
|
|
"ref" = REF(container)
|
|
)
|
|
category_item["products"] += list(package_item)
|
|
|
|
packaging_types += list(category_item)
|
|
|
|
packaging_type = GLOB.reagent_containers[CAT_PILLS][1]
|
|
packaging_category = CAT_PILLS
|
|
max_volume = initial(packaging_type.volume)
|
|
current_volume = clamp(current_volume, MIN_VOLUME, max_volume)
|
|
|
|
AddComponent(/datum/component/plumbing/pill_press, layer)
|
|
|
|
/obj/machinery/plumbing/pill_press/process(seconds_per_tick)
|
|
if(!is_operational || reagents.total_volume < current_volume)
|
|
return
|
|
|
|
var/obj/item/reagent_containers/container = new packaging_type(src)
|
|
var/suffix
|
|
switch(packaging_category)
|
|
if(CAT_PILLS)
|
|
suffix = "pill"
|
|
if(CAT_PATCHES)
|
|
suffix = "patch"
|
|
//SKYRAT EDIT ADDITION BEGIN - HYPOVIALS
|
|
if(CAT_HYPOS)
|
|
suffix = "vial"
|
|
//SKYRAT EDIT ADDITION END - HYPOVIALS
|
|
if(CAT_PEN_INJECTORS)
|
|
// BUBBER EDIT for pen_medipens
|
|
suffix = "injector"
|
|
else
|
|
suffix = "bottle"
|
|
container.name = "[product_name] [suffix]"
|
|
reagents.trans_to(container, current_volume)
|
|
if (istype(container, /obj/item/reagent_containers/applicator/pill))
|
|
var/obj/item/reagent_containers/applicator/pill/pill = container
|
|
pill.layers_remaining = pill_duration
|
|
container.forceMove(drop_location())
|
|
|
|
use_energy(active_power_usage * seconds_per_tick)
|
|
|
|
/obj/machinery/plumbing/pill_press/ui_assets(mob/user)
|
|
return list(
|
|
get_asset_datum(/datum/asset/spritesheet_batched/chemmaster)
|
|
)
|
|
|
|
/obj/machinery/plumbing/pill_press/ui_interact(mob/user, datum/tgui/ui)
|
|
ui = SStgui.try_update_ui(user, src, ui)
|
|
if(!ui)
|
|
ui = new(user, src, "ChemPress", name)
|
|
ui.open()
|
|
|
|
/obj/machinery/plumbing/pill_press/ui_static_data(mob/user)
|
|
var/list/data = list()
|
|
|
|
data["min_volume"] = MIN_VOLUME
|
|
data["packaging_types"] = packaging_types
|
|
|
|
return data
|
|
|
|
/obj/machinery/plumbing/pill_press/ui_data(mob/user)
|
|
var/list/data = list()
|
|
|
|
data["current_volume"] = current_volume
|
|
data["pill_duration"] = pill_duration
|
|
data["max_volume"] = max_volume
|
|
data["max_duration"] = PILL_MAX_LAYERS
|
|
data["product_name"] = product_name
|
|
data["packaging_type"] = REF(packaging_type)
|
|
data["packaging_category"] = packaging_category
|
|
|
|
return data
|
|
|
|
/obj/machinery/plumbing/pill_press/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
|
. = ..()
|
|
if(.)
|
|
return
|
|
|
|
switch(action)
|
|
if("change_current_volume")
|
|
var/value = params["volume"]
|
|
if(isnull(value))
|
|
return FALSE
|
|
|
|
value = text2num(value)
|
|
if(isnull(value))
|
|
return FALSE
|
|
|
|
current_volume = clamp(value, MIN_VOLUME, max_volume)
|
|
return TRUE
|
|
|
|
if("change_pill_duraton")
|
|
var/value = params["duration"]
|
|
if(isnull(value))
|
|
return FALSE
|
|
|
|
value = text2num(value)
|
|
if(isnull(value))
|
|
return FALSE
|
|
|
|
pill_duration = clamp(value, 0, PILL_MAX_LAYERS)
|
|
return TRUE
|
|
|
|
if("change_product_name")
|
|
var/formatted_name = html_encode(params["name"])
|
|
if (length(formatted_name) > MAX_NAME_LEN)
|
|
product_name = copytext(formatted_name, 1, MAX_NAME_LEN + 1)
|
|
else
|
|
product_name = formatted_name
|
|
return TRUE
|
|
|
|
if("change_product")
|
|
var/container = params["ref"]
|
|
if(!container)
|
|
return FALSE
|
|
|
|
//is a valid option
|
|
var/container_found = FALSE
|
|
for(var/list/category as anything in packaging_types)
|
|
if(container_found)
|
|
break
|
|
for(var/list/package_item as anything in category["products"])
|
|
if(container == package_item["ref"])
|
|
container_found = TRUE
|
|
break
|
|
if(!container_found)
|
|
return FALSE
|
|
|
|
//decode container & its category
|
|
packaging_type = locate(container)
|
|
if(ispath(packaging_type, /obj/item/reagent_containers/applicator/patch))
|
|
packaging_category = CAT_PATCHES
|
|
else if(ispath(packaging_type, /obj/item/reagent_containers/applicator/pill))
|
|
packaging_category = CAT_PILLS
|
|
// BUBBER EDIT: added with pen_medipens - needed to properly name the injectors and fixes the hypovials
|
|
else if(ispath(packaging_type, /obj/item/reagent_containers/cup/vial))
|
|
packaging_category = CAT_HYPOS
|
|
else if(ispath(packaging_type, /obj/item/reagent_containers/hypospray/medipen/deforest/printable))
|
|
packaging_category = CAT_PEN_INJECTORS
|
|
// BUBBER EDIT END
|
|
else
|
|
packaging_category = "Bottles"
|
|
|
|
//get new volumes
|
|
max_volume = initial(packaging_type.volume)
|
|
current_volume = clamp(current_volume, MIN_VOLUME, max_volume)
|
|
return TRUE
|
|
|
|
#undef MIN_VOLUME
|
|
#undef MAX_FLOOR_PRODUCTS // BUBBER EDIT - ADDITION
|