ClumsyPenny Posted July 9, 2024 Share Posted July 9, 2024 (edited) Lots of mods want to add new Crock Pot recipes, but I've seen many complicate the process needlessly. So I'm here to provide a proper tutorial to make the process so much easier! Let's get into it. Creating a build The first step is to create a Spriter project. Name it whatever you want, but keep the name in mind, as this is the name of your build! For the sake of this tutorial, I'll use a mod I made as reference where I named the build "bigcrop_preparedfoods". In the project's folder, create a folder for EVERY dish you're planning to add, named after the prefab name of the dish. This is very important, as each folder is a symbol and they need to be different symbols. This is also how Klei does it. Spoiler Inside the folders, add the sprite of your dish. For image size, I recommend referencing existing foods, I'll provide a zipped folder of their extracted sprites attached to this post. Spoiler Once that's done, we can move to Spriter itself. We now need to set the pivot points of these sprites, it's what the game will use to center the sprites properly when dropped on the ground or when they show up in the Crock Pot. One by one, open each folder and double click the sprites to edit the pivot, and set the pivot around the center-bottom, wherever it would make sense for the item to sit if it was dropped on the floor. Spoiler Once you set the pivot for all of them, you're technically done, as Crock Pot foods only use symbol swaps, they don't need animations. But this is where I usually run into an issue, and if anyone has a better fix, please let me know! The problem is that since none of these sprites are used in an animation, the project doesn't register them and they don't get compiled. My dirty solution is to make an animation, name it whatever and drag each sprite into the animation, like this: Spoiler Again, this animation will never be used in-game, but it allows the sprites to compile properly. NOTE: This tutorial doesn't cover inventory images for the dishes. There's nothing special about how they should be handled, so it's out of the scope of this tutorial. Just don't forget to also create inventory images. Setting up recipe data Now it's time to set up all the relevant data for your recipes, like stats (hunger, health, sanity) and other relevant values. You can either do this in modmain itself, an extension of the modmain environment through modimport or inside a file in the scripts folder of your mod. For the sake of doing it the same way Klei does, I'll go with the latter option in this tutorial. Create a new .lua file inside your scripts folder, name it whatever, I'll go with "bigcrop_preparedfoods" again, but it doesn't have to be the same. In this file, declare a local table, with each entry having the prefab name of your dish as the key, and the table of data as their value. Here's an exmaple: Spoiler local foods = { bigcrop_asparagussalad = { test = function(cooker, names, tags) return (names.asparagus or names.asparagus_cooked) and tags.veggie and tags.veggie >= 2 and not tags.meat and not tags.inedible and not tags.frozen end, priority = 10, foodtype = FOODTYPE.VEGGIE, health = TUNING.HEALING_LARGE, hunger = TUNING.CALORIES_MED, sanity = TUNING.SANITY_MED, perishtime = TUNING.PERISH_MED, temperature = -10, temperatureduration = TUNING.FOOD_TEMP_BRIEF, cooktime = 1, floater = {"small", 0.1, 0.8}, }, bigcrop_caramelarils = { test = function(cooker, names, tags) return (names.pomegranate or names.pomegranate_cooked) and tags.sweetener and names.twigs and not tags.meat end, priority = 20, foodtype = FOODTYPE.GOODIES, health = TUNING.HEALING_MEDSMALL, hunger = TUNING.CALORIES_SMALL, sanity = TUNING.SANITY_LARGE, perishtime = TUNING.PERISH_MED * 4, cooktime = 0.5, floater = {"small", 0.05, 0.35}, }, } Not every field is necessary, like "temperature" and "temperatureduration", but I recommend looking at the vanilla recipes as reference, especially for the "test" field, as it can be a bit difficult to wrap your head around it at first. But that's beyond the scope of this tutorial, I'm going to assume you have a good grasp on what a recipe needs. Once you've created the data for all your custom recipes, there's one last thing left to do for this section, which is iterating through the data and adding some important fields or adding a default for some values. Lastly, you have to make sure your file returns this table of foods, so here's what your file should roughly look like when finished: Spoiler local foods = { bigcrop_asparagussalad = { test = function(cooker, names, tags) return (names.asparagus or names.asparagus_cooked) and tags.veggie and tags.veggie >= 2 and not tags.meat and not tags.inedible and not tags.frozen end, priority = 10, foodtype = FOODTYPE.VEGGIE, health = TUNING.HEALING_LARGE, hunger = TUNING.CALORIES_MED, sanity = TUNING.SANITY_MED, perishtime = TUNING.PERISH_MED, temperature = -10, temperatureduration = TUNING.FOOD_TEMP_BRIEF, cooktime = 1, floater = {"small", 0.1, 0.8}, }, bigcrop_caramelarils = { test = function(cooker, names, tags) return (names.pomegranate or names.pomegranate_cooked) and tags.sweetener and names.twigs and not tags.meat end, priority = 20, foodtype = FOODTYPE.GOODIES, health = TUNING.HEALING_MEDSMALL, hunger = TUNING.CALORIES_SMALL, sanity = TUNING.SANITY_LARGE, perishtime = TUNING.PERISH_MED * 4, cooktime = 0.5, floater = {"small", 0.05, 0.35}, }, } for recipe,data in pairs(foods) do data.name = recipe data.bigcrop_moddish = true data.weight = data.weight or 1 data.priority = data.priority or 1 data.cooktime = data.cooktime or 0.5 data.overridebuild = "bigcrop_preparedfoods" data.cookbook_atlas = "images/bigcrop_cookbook.xml" end return foods data.name is for the name of your recipe, recipes are sometimes reference through the name field. data.bigcrop_moddish is a custom field that we'll use later, name it anything but it will be important. data.weight, priority and cooktime ideally should have a default value. priority decides which dish gets picked if multiple are valid, weight makes one dish more or less likely than another with the same priority (this is unused by Klei), and cooktime is the cooking multiplier (20 seconds times the cooktime is how long it takes, so a cooktime of 0.5 is 10 seconds). data.overridebuild is very important, and you need to name it the same as the build mentioned earlier in this tutorial. data.cookbook_atlas is entirely optional, but Cookbook images default to the inventory image, which is only 64x64 so it will look blurry in the Cookbook. You can create your own atlas for the Cookbook, I recommend 256x256 if you're particular about this detail. Adding the recipes You've created the symbols, you've created the data, now it's time to tell the game to properly register these recipes and create the prefab themselves. In the modmain envinronment, set up some code like this: Spoiler local Cooking = require("cooking") local PreparedFoods = require("preparedfoods") local SpicedFoods = require("spicedfoods") local BigCrop_PreparedFoods = require("bigcrop_preparedfoods") for recipe,data in pairs(BigCrop_PreparedFoods) do AddCookerRecipe("cookpot", data) AddCookerRecipe("portablecookpot", data) AddCookerRecipe("archive_cookpot", data) PreparedFoods[recipe] = data end GLOBAL.GenerateSpicedFoods(BigCrop_PreparedFoods) for name,data in pairs(SpicedFoods) do if Cooking.recipes.portablespicer[data.name] == nil and data.bigcrop_moddish then AddCookerRecipe("portablespicer", data) end end This is a bit much, so let's go through it: You need to "require" all the relevant files, including your own file in scripts you made earlier in the tutorial. These files return data that we're going to need or add to it. Iterate through your recipes, and add them to the relevant cookers through AddCookerRecipe. This is needed so that they will actually be able to show up when cooking. Add your recipe to Klei's PreparedFoods. This will make it so the game will automatically create prefabs for your dishes (except spiced, they are covered next). If you want your dishes to also support Warly's spices, then you need to generate them with GLOBAL.GenerateSpicedFoods. This handles automatically creating the relevant data for them. Unfortunately, the spiced dishes are not automatically added to the Portable Seasoning Station, so here you will iterate through every SpicedFoods, check if they're registered and check if they have our value (bigcrop_moddish for me, but change it to your value. This check is needed so we don't interfere with other mods). If not, then we use AddCookerRecipe to add them to the Portable Seasoning Station. Finishing touches If you've followed every step, there's a few finishing touches you can do to polish your mod: If you don't like how the food sits on the Crock Pot after it's made, you can either move the pivot around, or add the field "potlevel" to that dish's data. potlevel can be "high", "low" or leave it as nil for medium, which is default. If you want your dish (and its spiced variants) to have certain tags, you can add the field "tags" to its data. The field should contain a table of strings, with each string being a tag that will be added to the dish. If you tried dropping your dish in the water and the floating effect didn't look right, adjust the floater field in the data accordingly. This is something that usually needs to be done for every inventory item. Conclusion I never made a tutorial on these forums before, so I hope I was able to explain things well enough. If you have any more questions or think I should explain a part of this tutorial better, feel free to let me know! crock pot foods.zip Edited July 12, 2024 by ClumsyPenny 4 Link to comment https://forums.kleientertainment.com/forums/topic/158105-tutorial-how-to-create-custom-crock-pot-dishes-and-spiced-variants/ Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now