/client/proc/recipe_dump() set name = "Generate Recipe Dump" set category = "Server" set desc = "Dumps food and drink recipe info and images for wiki or other use." if(!holder) return //////////////////////// DRINK var/list/drink_recipes = list() for(var/path in typesof(/datum/chemical_reaction/drinks) - /datum/chemical_reaction/drinks) var/datum/chemical_reaction/drinks/CR = new path() drink_recipes[path] = list("Result" = CR.name, "ResAmt" = CR.result_amount, "Reagents" = CR.required_reagents) qdel(CR) //////////////////////// FOOD var/list/food_recipes = typesof(/datum/recipe) - /datum/recipe //Build a useful list for(var/Rp in food_recipes) //Lists don't work with datum-stealing no-instance initial() so we have to. var/datum/recipe/R = new Rp() var/obj/res = new R.result() var/icon/result_icon = icon(res.icon,res.icon_state) result_icon.Scale(64,64) food_recipes[Rp] = list( "Result" = "[res.name]", "ResAmt" = "1", "Reagents" = R.reagents, "Fruit" = R.fruit, "Ingredients" = R.items, "Image" = result_icon ) qdel(res) qdel(R) //////////////////////// FOOD+ (basically condiments, tofu, cheese, soysauce, etc) for(var/path in typesof(/datum/chemical_reaction/food) - /datum/chemical_reaction/food) var/datum/chemical_reaction/food/CR = new path() food_recipes[path] = list("Result" = CR.name, "ResAmt" = CR.result_amount, "Reagents" = CR.required_reagents, "Fruit" = list(), "Ingredients" = list(), "Image" = null) qdel(CR) //////////////////////// PROCESSING //Items needs further processing into human-readability. for(var/Rp in food_recipes) var/working_ing_list = list() for(var/I in food_recipes[Rp]["Ingredients"]) var/atom/ing = new I() //So now we add something like "Bread" = 3 if(ing.name in working_ing_list) var/sofar = working_ing_list[ing.name] working_ing_list[ing.name] = sofar+1 else working_ing_list[ing.name] = 1 food_recipes[Rp]["Ingredients"] = working_ing_list //Reagents can be resolved to nicer names as well for(var/Rp in food_recipes) for(var/rid in food_recipes[Rp]["Reagents"]) var/datum/reagent/Rd = chemical_reagents_list[rid] var/R_name = Rd.name var/amt = food_recipes[Rp]["Reagents"][rid] food_recipes[Rp]["Reagents"] -= rid food_recipes[Rp]["Reagents"][R_name] = amt for(var/Rp in drink_recipes) for(var/rid in drink_recipes[Rp]["Reagents"]) var/datum/reagent/Rd = chemical_reagents_list[rid] var/R_name = Rd.name var/amt = drink_recipes[Rp]["Reagents"][rid] drink_recipes[Rp]["Reagents"] -= rid drink_recipes[Rp]["Reagents"][R_name] = amt //////////////////////// SORTING var/list/foods_to_paths = list() var/list/drinks_to_paths = list() for(var/Rp in food_recipes) foods_to_paths["[food_recipes[Rp]["Result"]] [Rp]"] = Rp //Append recipe datum path to keep uniqueness for(var/Rp in drink_recipes) drinks_to_paths["[drink_recipes[Rp]["Result"]] [Rp]"] = Rp foods_to_paths = sortAssoc(foods_to_paths) drinks_to_paths = sortAssoc(drinks_to_paths) var/list/foods_newly_sorted = list() var/list/drinks_newly_sorted = list() for(var/Rr in foods_to_paths) var/Rp = foods_to_paths[Rr] foods_newly_sorted[Rp] = food_recipes[Rp] for(var/Rr in drinks_to_paths) var/Rp = drinks_to_paths[Rr] drinks_newly_sorted[Rp] = drink_recipes[Rp] food_recipes = foods_newly_sorted drink_recipes = drinks_newly_sorted //////////////////////// OUTPUT //Food Output var/html = "
\ \ \ \ \| Icon | Name | Ingredients | |
|---|---|---|---|
| No Image | "
//Name
html += "[food_recipes[Rp]["Result"]] | " //Ingredients html += "
| "
//Close this row
html += "
| Name | Ingredients |
|---|---|
| [drink_recipes[Rp]["Result"]] | " html += ""
//For each reagent
var/pretty_rea = ""
var/count = 0
for(var/rea in drink_recipes[Rp]["Reagents"])
pretty_rea += "[count == 0 ? "" : ", "][drink_recipes[Rp]["Reagents"][rea]]u [rea]"
count++
if(pretty_rea != "")
html += " | "
//Close this row
html += "