Minor boxstation changes, merges #4694 and #4697

This commit is contained in:
deathride58
2018-01-08 00:53:37 -05:00
parent 3f766f9054
commit 7280d91628
8 changed files with 3505 additions and 1627 deletions
@@ -53,6 +53,8 @@
"toxin"
)
var/list/saved_recipes = list()
/obj/machinery/chem_dispenser/Initialize()
. = ..()
cell = new cell_type
@@ -136,6 +138,7 @@
data["beakerTransferAmounts"] = null
var/chemicals[0]
var/recipes[0]
var/is_hallucinating = FALSE
if(user.hallucinating())
is_hallucinating = TRUE
@@ -146,7 +149,10 @@
if(is_hallucinating && prob(5))
chemname = "[pick_list_replacements("hallucination.json", "chemicals")]"
chemicals.Add(list(list("title" = chemname, "id" = temp.id)))
for(var/recipe in saved_recipes)
recipes.Add(list(recipe))
data["chemicals"] = chemicals
data["recipes"] = recipes
return data
/obj/machinery/chem_dispenser/ui_act(action, params)
@@ -179,6 +185,37 @@
beaker = null
cut_overlays()
. = TRUE
if("dispense_recipe")
var/recipe_to_use = params["recipe"]
var/list/chemicals_to_dispense = process_recipe_list(recipe_to_use)
for(var/r_id in chemicals_to_dispense) // i suppose you could edit the list locally before passing it
if(beaker && dispensable_reagents.Find(r_id)) // but since we verify we have the reagent, it'll be fine
var/datum/reagents/R = beaker.reagents
var/free = R.maximum_volume - R.total_volume
var/actual = min(chemicals_to_dispense[r_id], (cell.charge * powerefficiency)*10, free)
if(actual)
R.add_reagent(r_id, actual)
cell.use((actual / 10) / powerefficiency)
if("clear_recipes")
var/yesno = alert("Clear all recipes?",, "Yes","No")
if(yesno == "Yes")
saved_recipes = list()
if("add_recipe")
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(name && recipe)
var/list/first_process = splittext(recipe, ";")
if(!LAZYLEN(first_process))
return
for(var/reagents in first_process)
var/list/fuck = splittext(reagents, "=")
if(dispensable_reagents.Find(fuck[1]))
continue
else
var/temp = fuck[1]
to_chat(usr, "[src] can't process [temp]!")
return
saved_recipes += list(list("recipe_name" = name, "contents" = recipe))
/obj/machinery/chem_dispenser/attackby(obj/item/I, mob/user, params)
if(default_unfasten_wrench(user, I))
@@ -310,6 +347,14 @@
beaker = null
return ..()
/obj/machinery/chem_dispenser/proc/process_recipe_list(var/fucking_hell)
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(fuck[1] = text2num(fuck[2]))
return final_list
/obj/machinery/chem_dispenser/drinks
name = "soda dispenser"
desc = "Contains a large reservoir of soft drinks."