diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 91a504f421..8dbfae61ec 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -161,7 +161,8 @@ var/list/admin_verbs_server = list( /client/proc/toggle_random_events, /client/proc/check_customitem_activity, /client/proc/nanomapgen_DumpImage, - /client/proc/modify_server_news + /client/proc/modify_server_news, + /client/proc/recipe_dump ) var/list/admin_verbs_debug = list( /client/proc/getruntimelog, //allows us to access runtime logs to somebody, diff --git a/code/modules/food/recipe_dump.dm b/code/modules/food/recipe_dump.dm new file mode 100644 index 0000000000..f33be27258 --- /dev/null +++ b/code/modules/food/recipe_dump.dm @@ -0,0 +1,129 @@ +/client/proc/recipe_dump() + set name = "Generate Recipe Dump" + set category = "Server" + set desc = "Dumps food recipe info and images for wiki or other use." + + if(!holder) + return + + var/list/recipe_paths = typesof(/datum/recipe) - /datum/recipe + //Build a useful list + for(var/Rp in recipe_paths) + //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) + + recipe_paths[Rp] = list( + "Result" = "[res.name]", + "Reagents" = R.reagents, + "Fruit" = R.fruit, + "Ingredients" = R.items, + "Image" = result_icon + ) + + qdel(res) + qdel(R) + + //Items needs further processing into human-readability. Another use of initial. + var/working_ing_list = list() + for(var/I in recipe_paths[Rp]["Ingredients"]) + var/atom/ing = new I() + + //So now we add something like "Bread" = 3 + if(ing.name in working_ing_list) + working_ing_list[ing.name] = working_ing_list[ing.name]++ + else + working_ing_list[ing.name] = 1 + + recipe_paths[Rp]["Ingredients"] = working_ing_list + + //Reagents can be resolved to nicer names as well + for(var/rid in recipe_paths[Rp]["Reagents"]) + var/datum/reagent/Rd = chemical_reagents_list[rid] + var/R_name = Rd.name + recipe_paths[Rp]["Reagents"][R_name] += recipe_paths[Rp]["Reagents"][rid] + recipe_paths[Rp]["Reagents"] -= rid + + //Sort list by transforming into resultname+unique = path, then back in the right order + //Can't just be sorted by resultname since they are not unique and lists indexed by that will + //end up overwriting the several ways to make something with a single one + var/list/names_to_paths = list() + for(var/Rp in recipe_paths) + names_to_paths["[recipe_paths[Rp]["Result"]] [Rp]"] = Rp //Append recipe datum path to keep uniqueness + + names_to_paths = sortAssoc(names_to_paths) + + var/list/newly_sorted = list() + for(var/Rr in names_to_paths) + var/Rp = names_to_paths[Rr] + newly_sorted[Rp] = recipe_paths[Rp] + + recipe_paths = newly_sorted + + //Produce Output + var/html = "
\ + \ + \ + \ + \ +| Icon | Name | Ingredients |
|---|---|---|
| [recipe_paths[Rp]["Result"]] | " + + //Ingredients + html += "
| "
+ //Close this row
+ html += "