generalizes recipe searching, adds chemistry functionality

This commit is contained in:
Timothy Teakettle
2022-02-23 11:38:04 +00:00
parent 4adb870324
commit 56547a2556
4 changed files with 42 additions and 26 deletions
+30 -2
View File
@@ -27,7 +27,8 @@
//Randomized need to go last since they need to check against conflicts with normal recipes
var/paths = subtypesof(/datum/chemical_reaction) - typesof(/datum/chemical_reaction/randomized) + subtypesof(/datum/chemical_reaction/randomized)
GLOB.chemical_reactions_list = list()
GLOB.drink_reactions_list = list()
GLOB.normalized_chemical_reactions_list = list() // chemistry pda
GLOB.drink_reactions_list = list() // bartender pda
for(var/path in paths)
@@ -35,9 +36,11 @@
var/list/reaction_ids = list()
// store drinks separately for bartender cartridge
if(D.id)
var/datum/reagent/r = D.id
if(ispath(D.id, /datum/reagent/consumable))
var/datum/reagent/consumable/r = D.id
GLOB.drink_reactions_list[initial(r.name)] = D
if(ispath(D.id, /datum/reagent))
GLOB.normalized_chemical_reactions_list[initial(r.name)] = D
if(D.required_reagents && D.required_reagents.len)
for(var/reaction in D.required_reagents)
@@ -50,6 +53,31 @@
GLOB.chemical_reactions_list[id] += D
break // Don't bother adding ourselves to other reagent ids, it is redundant
/proc/recipe_search(mob/M, list/reaction_list)
var/option = input(M, "Enter keyword to return a recipe.")
if(option)
option = lowertext(option)
var/list/reagents_required
var/found_reagent_name
var/required_temp
for(var/reagent_name in reaction_list)
if(findtext(lowertext(reagent_name), option))
var/datum/chemical_reaction/reaction = reaction_list[reagent_name]
found_reagent_name = reagent_name
reagents_required = reaction.required_reagents
required_temp = reaction.required_temp
break
if(length(reagents_required))
to_chat(M, "<b>Recipe found: [found_reagent_name]</b>[required_temp ? "<br>Required Temperature: [required_temp]K" : ""]<br>Required Reagents:")
var/reagents_required_string = ""
for(var/r in reagents_required)
var/datum/reagent/reagent = r
reagents_required_string += "<br>[initial(reagent.name)]: [reagents_required[r]]"
to_chat(M, reagents_required_string)
return
else
to_chat(M, "<span class='warning'>Reagent with term: [option] could not be located!</span>")
///////////////////////////////////////////////////////////////////////////////////
/datum/reagents