Jump to content

Where are crockpot recipes/jellybeans in the game files?


Recommended Posts

I'm specifically looking for jellybeans, but I could also use some of the files from various crockpot recipes for a mod im working on.

I figure that they are all likely compiled under one file, but I can't find it...

 

I need to look at the lines of code for the jellybeans healing over time, and I want to see if that same effect can be applied to sanity and hunger, both positively and negatively.

Edited by Ogrecakes
Link to comment
Share on other sites

Well, as you might have noticed, most of the recipes aren't exactly static. You can find the "recipes" in the preparedfoods.lua file (in the "scripts folder, not the file of the same name in the "prefabs" folder), but the "recipes" are in script-form written as test-functions which assert whether the "rules" of the "recipe" are upheld, given the ingredients in the cookpot.

It works like this:

  • The cookpot requires 4 items for any recipe.
  • Its widget only allows certain items to be put into it (it has to be added to the list of ingredients in cooking.lua).
  • Each ingredient is assigned tagged values in cooking.lua e.g. the "fish" and "eel" prefabs are assigned these tag-values {meat=.5,fish=1}, so two "fish" / "eel" prefabs (items) equal 1 meat (tag) but also equal 2 fish (tag), and the usefulness of these two facts depend on which recipe we are testing "rules" for (as you will see below).
    For completeness, here is the code that adds these tag-values:
    AddIngredientValues({"fish", "eel"}, {meat=.5,fish=1}, true)
    Parameters are: (list of prefab names, dictionary of tags and values, cancook, candry)

This affords a very dynamic method of figuring out which outcome a certain combination of ingredients will produce, and it affords very advanced scripting. Let's take an example. These are the rules ("recipe") for fishsticks:

test = function(cooker, names, tags)
	return
		tags.fish
		and names.twigs
		and (tags.inedible and tags.inedible <= 1)
end

The test function is passed an instance of the cooker (usually the cookpot), a table/list of the names of the ingredient prefabs, and "tags". The "tags" parameter is a table/dictionary (or an object..I dunno...same thing to us for the purpose of explaining) which has entries with the combined tags of the given ingredients as the keys and the summed up values for each tag. NOTE: These tags are NOT to be confused with tags on prefabs. As noted earlier, these tags are set in cooking.lua.

The fishsticks recipe requires:

  • tags.fish, which means there just has to be an entry in the tags dictionary for "fish", so as long as there is at least 1 fish or eel among the ingredients, this check passes i.e. the number of fish ingredients and the tag-value does not matter.
  • names.twigs, which means there just has to be at least one prefab with the name "twigs" among the ingredients.
  • (tags.inedible and tags.inedible <= 1), which means there has to be an entry in the tags dictionary for "inedible" AND the VALUE of the "inedible" tag must be less than or equal to 1 (Remember: the tag's value in the dictionary is the combined tag-values of all ingredients with the given tag). This means, that since the "twigs" prefab (item) is given a value of 1 for its "inedible" tag in cooking.lua, you can only have one "twigs" (item) among the ingredients. Now, "twigs" is the ONLY ingredient that has the "inedible" tag, but if another ingredient with that tag is added later or with mods, then you could not use that ingredient as filler when making fishsticks, as the VALUE of the "inedible" tag would become higher than 1.

Let's take another example. These are the rules for "ice cream":

test = function(cooker, names, tags)
	return
		tags.frozen
		and tags.dairy
		and tags.sweetener
		and not tags.meat
		and not tags.veggie
		and not tags.inedible
		and not tags.egg
end

This one runs purely on available tags among the recipes, and doesn't care about their values, but it excludes quite a lot of tags.

  • tags.frozen, which means at least one ingredient with the frozen tag
  • tags.dairy, which means at least one ingredient with the dairy tag
  • tags.sweetener, which means at least one ingredient with the sweetener tag

Those are the required tags. Assuming you cannot fill more than one of these requirements with any ingredient, you now must have three ingredients in your cookpot. If you wanted to mess this up, you could make a new ingredient which is both frozen AND a sweetener e.g. frozen honey, or one that is both a dairy AND a sweetener e.g. sweetened condensed milk.
Anyway, on to the forbidden ingredients:

  • not tags.meat, which means NO ingredients with the "meat" tag
  • not tags.veggie, which means NO ingredients with the "veggie" tag
  • not tags.inedible, which means NO ingredients with the "inedible" tag (sorry, twigs)
  • not tags.egg, which means NO ingredients with the "egg" tag

This means that, assuming you covered the required tags with three ingredients (none of which can have one of the forbidden tags), your fourth item (the filler) can be any ingredient which does not have one of the forbidden tags. Since there are no amount-restrictions on this one, you can simply put in an extra one of the three ingredients you used to cover the required tags

So how do we work with this system?

In order to change an existing recipe, I think you just need to include require("cooking") in your code, and then use the GetRecipe function to retrieve the current recipe, then you can change it, and then use the AddCookerRecipe function to overwrite the current recipe.

On to your other questions about "special food" (jellybeans)

Now, for the health regen from jellybeans, you will find part of that in preparedfoods.lua, where jellybeans are given an oneatenfn function, which is executed when it is eaten. If the eater has the "debuffable" component on, and is otherwise a valid target, the "healthregenbuff" (which is a prefab itself) is added to the eater's "debuffable" component's list of debuffs. If you take a look at the code in the prefab healthregenbuff.lua you will see that it is littered with jellybean-specific values.

For your purposes you might be content with simply changing the way the "healthregenbuff" prefab works, which shouldn't be too hard (use AddPrefabPostInit). It really depends what you want to achieve.

Edited by Ultroman
Link to comment
Share on other sites

Exactly what I needed, I made the mistake of looking for specific items when I should have been looking for tags instead.

Glad you made sure to cover all the bases, you answered litterally every question I could have had about this topic.

 

THANK

Link to comment
Share on other sites

Not your mistake, really. This system is bloody weird ^^

When I saw how it was built, I just thought I had to document it for anyone searching for this in the future.

Btw, please do report back if you find out if my suggestions work. It'd be nice for completeness ;)

Edited by Ultroman
Link to comment
Share on other sites

6 hours ago, Ultroman said:

Not your mistake, really. This system is bloody weird ^^

When I saw how it was built, I just thought I had to document it for anyone searching for this in the future.

Btw, please do report back if you find out if my suggestions work. It'd be nice for completeness ;)

Yup, I was able to tag some custom items to be used for crockpot recipes, and I was able to just rework the healthbuff code to apply to hunger and sanity too, both positive and negative.

Works perfectly!

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...