mirror of
https://github.com/SPLURT-Station/S.P.L.U.R.T-Station-13.git
synced 2025-12-10 18:02:57 +00:00
Initial Commit
This commit is contained in:
@@ -31,8 +31,8 @@
|
||||
var/working_state = "dispenser_working"
|
||||
var/nopower_state = "dispenser_nopower"
|
||||
var/has_panel_overlay = TRUE
|
||||
var/macrotier = 1
|
||||
var/obj/item/reagent_containers/beaker = null
|
||||
//dispensable_reagents is copypasted in plumbing synthesizers. Please update accordingly. (I didn't make it global because that would limit custom chem dispensers)
|
||||
var/list/dispensable_reagents = list(
|
||||
/datum/reagent/hydrogen,
|
||||
/datum/reagent/lithium,
|
||||
@@ -61,7 +61,7 @@
|
||||
/datum/reagent/bromine,
|
||||
/datum/reagent/stable_plasma
|
||||
)
|
||||
//these become available once upgraded.
|
||||
//These become available once upgraded.
|
||||
var/list/upgrade_reagents = list(
|
||||
/datum/reagent/oil,
|
||||
/datum/reagent/ammonia,
|
||||
@@ -87,20 +87,17 @@
|
||||
/datum/reagent/toxin/histamine,
|
||||
/datum/reagent/medicine/morphine
|
||||
)
|
||||
var/list/recording_recipe
|
||||
|
||||
var/list/saved_recipes = list()
|
||||
|
||||
/obj/machinery/chem_dispenser/Initialize()
|
||||
. = ..()
|
||||
dispensable_reagents = sortList(dispensable_reagents, /proc/cmp_reagents_asc)
|
||||
if(emagged_reagents)
|
||||
emagged_reagents = sortList(emagged_reagents, /proc/cmp_reagents_asc)
|
||||
if(upgrade_reagents)
|
||||
upgrade_reagents = sortList(upgrade_reagents, /proc/cmp_reagents_asc)
|
||||
if(upgrade_reagents2)
|
||||
upgrade_reagents2 = sortList(upgrade_reagents2, /proc/cmp_reagents_asc)
|
||||
if(upgrade_reagents3)
|
||||
upgrade_reagents3 = sortList(upgrade_reagents3, /proc/cmp_reagents_asc)
|
||||
dispensable_reagents = sortList(dispensable_reagents, /proc/cmp_reagents_asc)
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/chem_dispenser/Destroy()
|
||||
@@ -116,15 +113,6 @@
|
||||
. += "<span class='notice'>The status display reads:\n\
|
||||
Recharging <b>[recharge_amount]</b> power units per interval.\n\
|
||||
Power efficiency increased by <b>[round((powerefficiency*1000)-100, 1)]%</b>.</span>"
|
||||
switch(macrotier)
|
||||
if(1)
|
||||
. += "<span class='notice'>Macro granularity at <b>5u</b>.<span>"
|
||||
if(2)
|
||||
. += "<span class='notice'>Macro granularity at <b>3u</b>.<span>"
|
||||
if(3)
|
||||
. += "<span class='notice'>Macro granularity at <b>2u</b>.<span>"
|
||||
if(4)
|
||||
. += "<span class='notice'>Macro granularity at <b>1u</b>.<span>"
|
||||
|
||||
/obj/machinery/chem_dispenser/process()
|
||||
if (recharge_counter >= 4)
|
||||
@@ -160,7 +148,6 @@
|
||||
beaker_overlay = display_beaker()
|
||||
add_overlay(beaker_overlay)
|
||||
|
||||
|
||||
/obj/machinery/chem_dispenser/emag_act(mob/user)
|
||||
. = ..()
|
||||
if(obj_flags & EMAGGED)
|
||||
@@ -226,7 +213,6 @@
|
||||
data["beakerCurrentpH"] = null
|
||||
|
||||
var/chemicals[0]
|
||||
var/recipes[0]
|
||||
var/is_hallucinating = FALSE
|
||||
if(user.hallucinating())
|
||||
is_hallucinating = TRUE
|
||||
@@ -237,10 +223,10 @@
|
||||
if(is_hallucinating && prob(5))
|
||||
chemname = "[pick_list_replacements("hallucination.json", "chemicals")]"
|
||||
chemicals.Add(list(list("title" = chemname, "id" = ckey(temp.name))))
|
||||
for(var/recipe in saved_recipes)
|
||||
recipes.Add(list(recipe))
|
||||
data["chemicals"] = chemicals
|
||||
data["recipes"] = recipes
|
||||
data["recipes"] = saved_recipes
|
||||
|
||||
data["recordingRecipe"] = recording_recipe
|
||||
return data
|
||||
|
||||
/obj/machinery/chem_dispenser/ui_act(action, params)
|
||||
@@ -258,24 +244,28 @@
|
||||
if("dispense")
|
||||
if(!is_operational() || QDELETED(cell))
|
||||
return
|
||||
var/reagent = GLOB.name2reagent[params["reagent"]]
|
||||
if(beaker && dispensable_reagents.Find(reagent))
|
||||
var/datum/reagents/R = beaker.reagents
|
||||
var/free = R.maximum_volume - R.total_volume
|
||||
var/actual = min(amount, (cell.charge * powerefficiency)*10, free)
|
||||
var/reagent_name = params["reagent"]
|
||||
if(!recording_recipe)
|
||||
var/reagent = GLOB.name2reagent[reagent_name]
|
||||
if(beaker && dispensable_reagents.Find(reagent))
|
||||
var/datum/reagents/R = beaker.reagents
|
||||
var/free = R.maximum_volume - R.total_volume
|
||||
var/actual = min(amount, (cell.charge * powerefficiency)*10, free)
|
||||
|
||||
if(!cell.use(actual / powerefficiency))
|
||||
say("Not enough energy to complete operation!")
|
||||
return
|
||||
R.add_reagent(reagent, actual)
|
||||
if(!cell.use(actual / powerefficiency))
|
||||
say("Not enough energy to complete operation!")
|
||||
return
|
||||
R.add_reagent(reagent, actual)
|
||||
|
||||
work_animation()
|
||||
. = TRUE
|
||||
work_animation()
|
||||
else
|
||||
recording_recipe[reagent_name] += amount
|
||||
. = TRUE
|
||||
if("remove")
|
||||
if(!is_operational())
|
||||
if(!is_operational() || recording_recipe)
|
||||
return
|
||||
var/amount = text2num(params["amount"])
|
||||
if(beaker && (amount in beaker.possible_transfer_amounts))
|
||||
if(beaker && amount in beaker.possible_transfer_amounts)
|
||||
beaker.reagents.remove_all(amount)
|
||||
work_animation()
|
||||
. = TRUE
|
||||
@@ -285,57 +275,65 @@
|
||||
if("dispense_recipe")
|
||||
if(!is_operational() || QDELETED(cell))
|
||||
return
|
||||
var/recipe_to_use = params["recipe"]
|
||||
var/list/chemicals_to_dispense = process_recipe_list(recipe_to_use)
|
||||
var/res = get_macro_resolution()
|
||||
for(var/key in chemicals_to_dispense) // i suppose you could edit the list locally before passing it
|
||||
var/list/keysplit = splittext(key," ")
|
||||
var/r_id = GLOB.name2reagent[translate_legacy_chem_id(keysplit[1])]
|
||||
if(beaker && dispensable_reagents.Find(r_id)) // but since we verify we have the reagent, it'll be fine
|
||||
var/list/chemicals_to_dispense = saved_recipes[params["recipe"]]
|
||||
if(!LAZYLEN(chemicals_to_dispense))
|
||||
return
|
||||
for(var/key in chemicals_to_dispense)
|
||||
var/reagent = GLOB.name2reagent[translate_legacy_chem_id(key)]
|
||||
var/dispense_amount = chemicals_to_dispense[key]
|
||||
if(!dispensable_reagents.Find(reagent))
|
||||
return
|
||||
if(!recording_recipe)
|
||||
if(!beaker)
|
||||
return
|
||||
var/datum/reagents/R = beaker.reagents
|
||||
var/free = R.maximum_volume - R.total_volume
|
||||
var/actual = min(max(chemicals_to_dispense[key], res), (cell.charge * powerefficiency)*10, free)
|
||||
var/actual = min(dispense_amount, (cell.charge * powerefficiency)*10, free)
|
||||
if(actual)
|
||||
if(!cell.use(actual / powerefficiency))
|
||||
say("Not enough energy to complete operation!")
|
||||
return
|
||||
R.add_reagent(r_id, actual)
|
||||
R.add_reagent(reagent, actual)
|
||||
work_animation()
|
||||
else
|
||||
recording_recipe[key] += dispense_amount
|
||||
. = TRUE
|
||||
if("clear_recipes")
|
||||
if(!is_operational())
|
||||
return
|
||||
var/yesno = alert("Clear all recipes?",, "Yes","No")
|
||||
if(yesno == "Yes")
|
||||
saved_recipes = list()
|
||||
if("add_recipe")
|
||||
. = TRUE
|
||||
if("record_recipe")
|
||||
if(!is_operational())
|
||||
return
|
||||
recording_recipe = list()
|
||||
. = TRUE
|
||||
if("save_recording")
|
||||
if(!is_operational())
|
||||
return
|
||||
var/name = stripped_input(usr,"Name","What do you want to name this recipe?", "Recipe", MAX_NAME_LEN)
|
||||
var/recipe = stripped_input(usr,"Recipe","Insert recipe with chem IDs")
|
||||
if(!usr.canUseTopic(src, !issilicon(usr)))
|
||||
return
|
||||
if(name && recipe)
|
||||
var/list/first_process = splittext(recipe, ";")
|
||||
if(!LAZYLEN(first_process))
|
||||
return
|
||||
var/res = get_macro_resolution()
|
||||
var/resmismatch = FALSE
|
||||
for(var/reagents in first_process)
|
||||
var/list/reagent = splittext(reagents, "=")
|
||||
var/reagent_id = GLOB.name2reagent[translate_legacy_chem_id(reagent[1])]
|
||||
if(dispensable_reagents.Find(reagent_id))
|
||||
if (!resmismatch && !check_macro_part(reagents, res))
|
||||
resmismatch = TRUE
|
||||
continue
|
||||
else
|
||||
var/chemid = reagent[1]
|
||||
if(saved_recipes[name] && alert("\"[name]\" already exists, do you want to overwrite it?",, "Yes", "No") == "No")
|
||||
return
|
||||
if(name && recording_recipe)
|
||||
for(var/reagent in recording_recipe)
|
||||
var/reagent_id = GLOB.name2reagent[translate_legacy_chem_id(reagent)]
|
||||
if(!dispensable_reagents.Find(reagent_id))
|
||||
visible_message("<span class='warning'>[src] buzzes.</span>", "<span class='italics'>You hear a faint buzz.</span>")
|
||||
to_chat(usr, "<span class ='danger'>[src] cannot find Chemical ID: <b>[chemid]</b>!</span>")
|
||||
to_chat(usr, "<span class ='danger'>[src] cannot find <b>[reagent]</b>!</span>")
|
||||
playsound(src, 'sound/machines/buzz-two.ogg', 50, 1)
|
||||
return
|
||||
if (resmismatch && alert("[src] is not yet capable of replicating this recipe with the precision it needs, do you want to save it anyway?",, "Yes","No") == "No")
|
||||
return
|
||||
saved_recipes += list(list("recipe_name" = name, "contents" = recipe))
|
||||
saved_recipes[name] = recording_recipe
|
||||
recording_recipe = null
|
||||
. = TRUE
|
||||
if("cancel_recording")
|
||||
if(!is_operational())
|
||||
return
|
||||
recording_recipe = null
|
||||
. = TRUE
|
||||
|
||||
/obj/machinery/chem_dispenser/attackby(obj/item/I, mob/user, params)
|
||||
if(default_unfasten_wrench(user, I))
|
||||
@@ -343,7 +341,6 @@
|
||||
if(default_deconstruction_screwdriver(user, icon_state, icon_state, I))
|
||||
update_icon()
|
||||
return
|
||||
|
||||
if(default_deconstruction_crowbar(I))
|
||||
return
|
||||
if(istype(I, /obj/item/reagent_containers) && !(I.item_flags & ABSTRACT) && I.is_open_container())
|
||||
@@ -384,7 +381,6 @@
|
||||
work_animation()
|
||||
visible_message("<span class='danger'>[src] malfunctions, spraying chemicals everywhere!</span>")
|
||||
|
||||
|
||||
/obj/machinery/chem_dispenser/RefreshParts()
|
||||
recharge_amount = initial(recharge_amount)
|
||||
var/newpowereff = 0.0666666
|
||||
@@ -395,14 +391,8 @@
|
||||
for(var/obj/item/stock_parts/capacitor/C in component_parts)
|
||||
recharge_amount *= C.rating
|
||||
for(var/obj/item/stock_parts/manipulator/M in component_parts)
|
||||
if (M.rating > macrotier)
|
||||
macrotier = M.rating
|
||||
if (M.rating > 1)
|
||||
if(M.rating > 3)
|
||||
dispensable_reagents |= upgrade_reagents
|
||||
if (M.rating > 2)
|
||||
dispensable_reagents |= upgrade_reagents2
|
||||
if (M.rating > 3)
|
||||
dispensable_reagents |= upgrade_reagents3
|
||||
powerefficiency = round(newpowereff, 0.01)
|
||||
|
||||
/obj/machinery/chem_dispenser/proc/replace_beaker(mob/living/user, obj/item/reagent_containers/new_beaker)
|
||||
@@ -422,41 +412,13 @@
|
||||
cell = null
|
||||
if(beaker)
|
||||
beaker.forceMove(drop_location())
|
||||
beaker = null
|
||||
return ..()
|
||||
|
||||
/obj/machinery/chem_dispenser/proc/get_macro_resolution()
|
||||
. = 5
|
||||
if (macrotier > 1)
|
||||
. -= macrotier // 5 for tier1, 3 for 2, 2 for 3, 1 for 4.
|
||||
|
||||
/obj/machinery/chem_dispenser/proc/check_macro(macro)
|
||||
var/res = get_macro_resolution()
|
||||
for (var/reagent in splittext(trim(macro), ";"))
|
||||
if (!check_macro_part(reagent, res))
|
||||
return FALSE
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/chem_dispenser/proc/check_macro_part(var/part, var/res = get_macro_resolution())
|
||||
var/detail = splittext(part, "=")
|
||||
if (round(text2num(detail[2]), res) != text2num(detail[2]))
|
||||
return FALSE
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/chem_dispenser/proc/process_recipe_list(var/fucking_hell)
|
||||
var/list/key_list = list()
|
||||
var/list/final_list = list()
|
||||
var/list/first_process = splittext(fucking_hell, ";")
|
||||
for(var/reagents in first_process)
|
||||
var/list/fuck = splittext(reagents, "=")
|
||||
final_list += list(avoid_assoc_duplicate_keys(fuck[1],key_list) = text2num(fuck[2]))
|
||||
return final_list
|
||||
|
||||
/obj/machinery/chem_dispenser/AltClick(mob/living/user)
|
||||
. = ..()
|
||||
if(!istype(user) || !user.canUseTopic(src, BE_CLOSE, FALSE, NO_TK))
|
||||
return
|
||||
replace_beaker(user)
|
||||
return TRUE
|
||||
..()
|
||||
if(istype(user) && user.canUseTopic(src, BE_CLOSE, FALSE, NO_TK))
|
||||
replace_beaker(user)
|
||||
|
||||
/obj/machinery/chem_dispenser/drinks/Initialize()
|
||||
. = ..()
|
||||
@@ -540,7 +502,6 @@
|
||||
/datum/reagent/toxin/staminatoxin
|
||||
)
|
||||
|
||||
|
||||
/obj/machinery/chem_dispenser/drinks/fullupgrade //fully ugpraded stock parts, emagged
|
||||
desc = "Contains a large reservoir of soft drinks. This model has had its safeties shorted out."
|
||||
obj_flags = CAN_BE_HIT | EMAGGED
|
||||
@@ -646,7 +607,7 @@
|
||||
/datum/reagent/ammonia,
|
||||
/datum/reagent/ash,
|
||||
/datum/reagent/diethylamine)
|
||||
//same as above.
|
||||
//same as above.
|
||||
upgrade_reagents = null
|
||||
upgrade_reagents2 = null
|
||||
upgrade_reagents3 = null
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,14 +1,42 @@
|
||||
<script>
|
||||
component.exports = {
|
||||
data: {
|
||||
upperCaseWrapper(lowercased) {
|
||||
return lowercased.toUpperCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<ui-display title='Status'>
|
||||
<ui-section label='Energy'>
|
||||
<ui-bar min='0' max='{{data.maxEnergy}}' value='{{data.energy}}'>{{Math.fixed(adata.energy)}} Units</ui-bar>
|
||||
</ui-section>
|
||||
</ui-display>
|
||||
|
||||
{{#if data.recordingRecipe && true}}
|
||||
<ui-notice>
|
||||
<span class='fa fa-circle'></span> <span>Recording</span>
|
||||
</ui-notice>
|
||||
<ui-display>
|
||||
<ui-subdisplay>
|
||||
{{#each data.recordingRecipe: chemical}}
|
||||
<ui-section label='{{chemical.replace(/\b\w/, upperCaseWrapper)}}'><span>{{adata.recordingRecipe[chemical]}}</span></ui-section>
|
||||
{{/each}}
|
||||
</ui-subdisplay>
|
||||
<ui-section>
|
||||
<ui-button icon='floppy-o' action='save_recording'>Save</ui-button>
|
||||
<ui-button icon='ban' action='cancel_recording'>Cancel</ui-button>
|
||||
</ui-section>
|
||||
</ui-display>
|
||||
{{/if}}
|
||||
|
||||
<ui-display title='Saved Recipes' button>
|
||||
<ui-section>
|
||||
<ui-button icon='plus' action='add_recipe'>Add Recipe</ui-button>
|
||||
<ui-button icon='minus' action='clear_recipes'>Clear Recipes</ui-button>
|
||||
{{#each data.recipes}}
|
||||
<ui-button grid icon='tint' action='dispense_recipe' params='{"recipe": "{{contents}}"}'>{{recipe_name}}</ui-button>
|
||||
<ui-button icon='plus' action='record_recipe' state='{{data.recordingRecipe ? "disabled" : null}}'>Record Recipe</ui-button>
|
||||
<ui-button icon='minus' action='clear_recipes' state='{{data.recordingRecipe ? "disabled" : null}}'>Clear Recipes</ui-button>
|
||||
{{#each data.recipes: recipe_name}}
|
||||
<ui-button grid icon='tint' action='dispense_recipe' params='{"recipe": "{{recipe_name}}"}'>{{recipe_name}}</ui-button>
|
||||
{{/each}}
|
||||
</ui-section>
|
||||
</ui-display>
|
||||
@@ -27,7 +55,7 @@
|
||||
<ui-display title='Beaker' button>
|
||||
{{#partial button}}
|
||||
{{#each data.beakerTransferAmounts}}
|
||||
<ui-button icon='minus' action='remove' params='{"amount": {{.}}}'>{{.}}</ui-button>
|
||||
<ui-button icon='minus' action='remove' params='{"amount": {{.}}}' state='{{data.recordingRecipe ? "disabled" : null}}'>{{.}}</ui-button>
|
||||
{{/each}}
|
||||
<ui-button icon='eject' state='{{data.isBeakerLoaded ? null : "disabled"}}' action='eject'>Eject</ui-button>
|
||||
{{/partial}}
|
||||
|
||||
Reference in New Issue
Block a user