mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 13:10:02 +01:00
# Conflicts: # README.md # code/__DEFINES/admin.dm # code/__DEFINES/melee.dm # code/_globalvars/traits/_traits.dm # code/controllers/subsystem/economy.dm # code/datums/components/crafting/crafting.dm # code/datums/elements/crusher_loot.dm # code/modules/antagonists/pirate/pirate_shuttle_equipment.dm # code/modules/clothing/suits/_suits.dm # code/modules/escape_menu/leave_body.dm # code/modules/jobs/job_types/_job.dm # code/modules/mining/equipment/mineral_scanner.dm # code/modules/mob/living/living.dm # code/modules/plumbing/plumbers/pill_press.dm # tgui/packages/tgui/interfaces/Vending.tsx
226 lines
7.3 KiB
Plaintext
226 lines
7.3 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
|
|
/// list of products stored in the machine, so we dont have 610 pills on one tile
|
|
var/list/stored_products = list()
|
|
|
|
/obj/machinery/plumbing/pill_press/Initialize(mapload, bolt, 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/simple_demand, bolt, layer)
|
|
|
|
/obj/machinery/plumbing/pill_press/Destroy(force)
|
|
QDEL_LAZYLIST(stored_products)
|
|
return ..()
|
|
|
|
/obj/machinery/plumbing/pill_press/examine(mob/user)
|
|
. = ..()
|
|
. += span_notice("\The [src] currently has [stored_products.len] stored. There needs to be less than [MAX_FLOOR_PRODUCTS] on the floor to continue dispensing.")
|
|
|
|
/obj/machinery/plumbing/pill_press/process(seconds_per_tick)
|
|
if(!is_operational)
|
|
return
|
|
|
|
//shift & check to account for floating point inaccuracies
|
|
if(reagents.total_volume >= current_volume)
|
|
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)
|
|
suffix = "injector"
|
|
// BUBBER EDIT for pen_medipens
|
|
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
|
|
stored_products += container
|
|
|
|
//dispense stored products on the floor
|
|
if(stored_products.len)
|
|
var/pill_amount = 0
|
|
for(var/obj/item/reagent_containers/thing in loc)
|
|
pill_amount++
|
|
if(pill_amount >= MAX_FLOOR_PRODUCTS) //too much so just stop
|
|
break
|
|
if(pill_amount < MAX_FLOOR_PRODUCTS && anchored)
|
|
var/atom/movable/AM = stored_products[1] //AM because forceMove is all we need
|
|
stored_products -= AM
|
|
AM.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
|