From 97ed91be265dd49418d44338ce09e4ece55ee678 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Mon, 1 May 2023 22:11:32 +0100 Subject: [PATCH] [MIRROR] Auto-wiki setup for soup [MDB IGNORE] (#20851) * Auto-wiki setup for soup (#74931) ## About The Pull Request Sets up an auto-wiki run for Soup. It's all in the in game cookbook, but keeping the wiki up to date is good. Still figuring out how auto-wiki works with the help of Smithers, so it might need to be updated in a follow-up PR. ``` {{Autowiki/SoupRecipeTemplate |name=Tomato Soup |taste=tomato |foodtypes=Vegetables, Fruits |description=Drinking this feels like being a vampire! A tomato vampire... |icon=soup/Tomato Soup |requirements=50 units Water, 2 tomatos, at temperature 450K |results=30 units Tomato Soup, 20 units Tomato Juice }} ``` Templates: https://tgstation13.org/wiki/Template:Autowiki/SoupRecipeTemplate https://tgstation13.org/wiki/Template:Autowiki/SoupRecipeTableTemplate * Auto-wiki setup for soup --------- Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> --- code/modules/autowiki/pages/soup.dm | 97 +++++++++++++++++++ .../food_and_drinks/recipes/soup_mixtures.dm | 38 +++++++- code/modules/hydroponics/grown/mushrooms.dm | 3 + .../chemistry/reagents/other_reagents.dm | 1 - tgstation.dme | 1 + 5 files changed, 137 insertions(+), 3 deletions(-) create mode 100644 code/modules/autowiki/pages/soup.dm diff --git a/code/modules/autowiki/pages/soup.dm b/code/modules/autowiki/pages/soup.dm new file mode 100644 index 00000000000..3134421a39a --- /dev/null +++ b/code/modules/autowiki/pages/soup.dm @@ -0,0 +1,97 @@ +/datum/autowiki/soup + page = "Template:Autowiki/Content/SoupRecipes" + +/datum/autowiki/soup/generate() + var/output = "" + + // Since we're here, generate a range icon since that's what is installed in most kitchens + var/obj/machinery/oven/range/range = new() + upload_icon(getFlatIcon(range, no_anim = TRUE), "kitchen_range") + qdel(range) + + // Also generate a soup pot icon, as that's what makes soup + var/obj/item/reagent_containers/cup/soup_pot/soup_pot = new() + upload_icon(getFlatIcon(soup_pot, no_anim = TRUE), "soup_pot") + qdel(soup_pot) + + var/container_for_images = /obj/item/reagent_containers/cup/bowl + + for(var/soup_recipe_type in subtypesof(/datum/chemical_reaction/food/soup)) + var/datum/chemical_reaction/food/soup/soup_recipe = new soup_recipe_type() + var/result_soup_type = soup_recipe.results[1] + var/datum/reagent/result_soup = new result_soup_type() + var/datum/glass_style/has_foodtype/soup_style = GLOB.glass_style_singletons[container_for_images][result_soup_type] + var/filename = "soup_[SANITIZE_FILENAME(escape_value(format_text(result_soup.name)))]" + + // -- Compiles a list of required reagents and food items -- + var/list/all_needs_text = list() + for(var/datum/reagent/reagent_type as anything in soup_recipe.required_reagents) + var/num_needed = soup_recipe.required_reagents[reagent_type] + all_needs_text += "[num_needed] units [initial(reagent_type.name)]" + + for(var/obj/item/food_type as anything in soup_recipe.required_ingredients) + var/num_needed = soup_recipe.required_ingredients[food_type] + // Instantiating this so we can do plurality correctly. + // We can use initial but it'll give us stuff like "eyballss". + var/obj/item/food = new food_type() + all_needs_text += "[num_needed] [food.name]\s" + qdel(food) + + all_needs_text += soup_recipe.describe_recipe_details() + all_needs_text += "At temperature [soup_recipe.required_temp]K" + var/compiled_requirements = "" + for(var/req_text in all_needs_text) + if(length(req_text)) + compiled_requirements += "
  • [req_text]
  • " + if(length(compiled_requirements)) + compiled_requirements = "" + + // -- Compiles a list of resulting reagents -- + var/list/all_results_text = list() + for(var/datum/reagent/reagent_type as anything in soup_recipe.results) + var/num_given = soup_recipe.results[reagent_type] + all_results_text += "[num_given] units [initial(reagent_type.name)]" + + all_results_text += soup_recipe.describe_result() + var/compiled_results = "" + for(var/res_text in all_results_text) + if(length(res_text)) + compiled_results += "
  • [res_text]
  • " + if(length(compiled_results)) + compiled_results = "" + + // -- Assemble the template list -- + var/list/template_list = list() + if(istype(soup_recipe, /datum/chemical_reaction/food/soup/custom)) + // Painful snowflaking here for custom recipes, + // but because they default to "bowl of water" we can't let it generate fully on its own. + template_list["name"] = "Custom Soup" + template_list["taste"] = "Whatever you use." + template_list["foodtypes"] = "Whatever you use." + template_list["description"] = "A custom soup recipe, allowing you to throw whatever you want in the pot." + + else + var/foodtypes_readable = jointext(bitfield_to_list(soup_style.drink_type, FOOD_FLAGS_IC), ", ") || "None" + var/tastes_actual = result_soup.get_taste_description() + template_list["name"] = escape_value(result_soup.name) + template_list["taste"] = escape_value(length(tastes_actual) ? capitalize(jointext(tastes_actual, ", ")) : "No taste") + template_list["foodtypes"] = escape_value(foodtypes_readable) + template_list["description"] = escape_value(result_soup.description) + + template_list["icon"] = escape_value(filename) + template_list["requirements"] = escape_value(compiled_requirements) + template_list["results"] = escape_value(compiled_results) + + // -- While we're here, generate an icon of the bowl -- + var/image/compiled_image = image(icon = soup_style.icon, icon_state = soup_style.icon_state) + upload_icon(getFlatIcon(compiled_image, no_anim = TRUE), filename) + + // -- Cleanup -- + qdel(result_soup) + qdel(soup_recipe) + + // -- All done, apply the template -- + output += include_template("Autowiki/SoupRecipeTemplate", template_list) + + // All that gets wrapped in another template which formats it into a table + return include_template("Autowiki/SoupRecipeTableTemplate", list("content" = output)) diff --git a/code/modules/food_and_drinks/recipes/soup_mixtures.dm b/code/modules/food_and_drinks/recipes/soup_mixtures.dm index 87eabd6a21c..9707c66010e 100644 --- a/code/modules/food_and_drinks/recipes/soup_mixtures.dm +++ b/code/modules/food_and_drinks/recipes/soup_mixtures.dm @@ -214,6 +214,16 @@ reagent.volume = round(reagent.volume * 0.9, 0.05) holder.update_total() +/// Adds text to the requirements list of the recipe +/// Return a list of strings, each string will be a new line in the requirements list +/datum/chemical_reaction/food/soup/proc/describe_recipe_details() + return + +/// Adds text to the results list of the recipe +/// Return a list of strings, each string will be a new line in the results list +/datum/chemical_reaction/food/soup/proc/describe_result() + return + #ifdef TESTING /obj/item/soup_test_kit/Initialize(mapload) @@ -272,16 +282,25 @@ ingredient_reagent_multiplier = 1 percentage_of_nutriment_converted = 0 + /// Custom recipes will not start mixing until at least this many solid ingredients are present + var/num_ingredients_needed = 3 + /datum/chemical_reaction/food/soup/custom/pre_reaction_other_checks(datum/reagents/holder) var/obj/item/reagent_containers/cup/soup_pot/pot = holder.my_atom if(!istype(pot)) return FALSE // Not a pot if(holder.is_reacting) return FALSE // Another soup is being made - if(length(pot.added_ingredients) <= 3) + if(length(pot.added_ingredients) <= num_ingredients_needed) return FALSE // Not a lot here to go off of return TRUE +/datum/chemical_reaction/food/soup/custom/describe_recipe_details() + return list("Created from burning soup with at least [num_ingredients_needed] ingredients present") + +/datum/chemical_reaction/food/soup/custom/describe_result() + return list("Whatever's in the pot") + // Meatball Soup /datum/reagent/consumable/nutriment/soup/meatball_soup name = "Meatball Soup" @@ -725,6 +744,8 @@ ) percentage_of_nutriment_converted = 0.33 // Full of garbage + /// Number of units of bonus reagent added + var/num_bonus = 10 /// A list of reagent types we can randomly gain in the soup on creation var/list/extra_reagent_types = list( /datum/reagent/blood, @@ -740,7 +761,14 @@ /datum/chemical_reaction/food/soup/mysterysoup/reaction_finish(datum/reagents/holder, datum/equilibrium/reaction, react_vol) . = ..() - holder.add_reagent(pick(extra_reagent_types), 10) + holder.add_reagent(pick(extra_reagent_types), num_bonus) + +/datum/chemical_reaction/food/soup/mysterysoup/describe_result() + var/list/extra_sublist = list() + for(var/datum/reagent/extra_type as anything in extra_reagent_types) + extra_sublist += "[initial(extra_type.name)]" + + return list("Will also contain [num_bonus] units of one randomly: [jointext(extra_sublist, ", ")]") // Monkey Soup /datum/reagent/consumable/nutriment/soup/monkey @@ -776,6 +804,9 @@ /datum/reagent/consumable/blackpepper = 4, ) +/datum/chemical_reaction/food/soup/monkey/describe_result() + return list("May contain a monkey.") + // Cream of mushroom soup /datum/reagent/consumable/nutriment/soup/mushroom name = "Chantrelle Soup" @@ -844,6 +875,9 @@ ) percentage_of_nutriment_converted = 0.1 +/datum/chemical_reaction/food/soup/beetsoup/describe_result() + return list("Changes name randomly to a common misspelling of \"Borscht\".") + // Stew /datum/reagent/consumable/nutriment/soup/stew name = "Stew" diff --git a/code/modules/hydroponics/grown/mushrooms.dm b/code/modules/hydroponics/grown/mushrooms.dm index 4be031db792..3e5b7c624bf 100644 --- a/code/modules/hydroponics/grown/mushrooms.dm +++ b/code/modules/hydroponics/grown/mushrooms.dm @@ -1,5 +1,8 @@ /obj/item/food/grown/mushroom name = "mushroom" + // This is a prototype that should never be spawned + // but we'll default it to SOME seed if it does end up spawning just so we don't runtime horribly + seed = /obj/item/seeds/chanter bite_consumption_mod = 3 foodtypes = VEGETABLES wine_power = 40 diff --git a/code/modules/reagents/chemistry/reagents/other_reagents.dm b/code/modules/reagents/chemistry/reagents/other_reagents.dm index 693babcff41..8b12b9e1c19 100644 --- a/code/modules/reagents/chemistry/reagents/other_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/other_reagents.dm @@ -19,7 +19,6 @@ desc = "Are you sure this is tomato juice?" icon_state = "glass_red" - // FEED ME /datum/reagent/blood/on_hydroponics_apply(obj/item/seeds/myseed, datum/reagents/chems, obj/machinery/hydroponics/mytray) if(!check_tray(chems, mytray)) diff --git a/tgstation.dme b/tgstation.dme index 6124c0b6024..19ab9de516b 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -2951,6 +2951,7 @@ #include "code\modules\atmospherics\machinery\portable\scrubber.dm" #include "code\modules\autowiki\autowiki.dm" #include "code\modules\autowiki\pages\base.dm" +#include "code\modules\autowiki\pages\soup.dm" #include "code\modules\autowiki\pages\techweb.dm" #include "code\modules\autowiki\pages\vending.dm" #include "code\modules\awaymissions\away_props.dm"