# More flexible recipe

**URL:** <https://discourse.cataclysmdda.org/t/more-flexible-recipe/15688>\
**Category:** The Drawing Board\
**Created:** [June 13, 2018, 10:12pm UTC](https://discourse.cataclysmdda.org/t/more-flexible-recipe/15688 "2018-06-13T22:12:21Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fris0uman](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/fris0uman/32/8607_2.png) [@Fris0uman](https://discourse.cataclysmdda.org/u/Fris0uman)\
**Post date:** [June 13, 2018, 10:12pm UTC](https://discourse.cataclysmdda.org/t/more-flexible-recipe/15688/1 "2018-06-13T22:12:21Z")

</div>

Let’s take the example of the basic chemistry set :

Components required:

> 1x pair of safety glasses  
> 3x rubber hose  
> 4x glass flask OR 4x glass jar OR 4x glass bottle  
> 1x cardboard box OR 1x canvas sack OR 1x backpack OR 1x leather backpack OR 1x military rucksack

With the current system if you have 3x glass flask AND 3x glass jar you can’t craft it, which is a bit frustrating since the recipe seems to suggest that glass jar and glass flask are equivalent. So it feels like you should be able to swap ONE fore the other.

So my question is : would it possible to make it so instead of : “4xA OR 4xB” , we get “4 amongst {A,B}” ? 4 Items within the list of valid ones ?

---

<div class="post-metadata">

**Author:** ![DeWolf](https://avatars.discourse-cdn.com/v4/letter/d/df705f/32.png) [@DeWolf](https://discourse.cataclysmdda.org/u/DeWolf)\
**Post date:** [June 13, 2018, 10:25pm UTC](https://discourse.cataclysmdda.org/t/more-flexible-recipe/15688/2 "2018-06-13T22:25:04Z")

</div>

I too would be interested in this.

---

<div class="post-metadata">

**Author:** ![mlangsdorf](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/mlangsdorf/32/2462_2.png) [@mlangsdorf](https://discourse.cataclysmdda.org/u/mlangsdorf)\
**Post date:** [June 14, 2018, 1:04am UTC](https://discourse.cataclysmdda.org/t/more-flexible-recipe/15688/3 "2018-06-14T01:04:39Z")

</div>

A lot of things are possible. This particular change requires teaching the code how to handle mixed ingredients, and then going through the json and changing all the recipes that should use mixed recipes to the new format. It’s a fairly big task.

I thought someone had written a pull request for this, but I can’t find it at github right now.

---

<div class="post-metadata">

**Author:** ![Fuscosco](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/fuscosco/32/1327_2.png) [@Fuscosco](https://discourse.cataclysmdda.org/u/Fuscosco)\
**Post date:** [June 14, 2018, 9:39am UTC](https://discourse.cataclysmdda.org/t/more-flexible-recipe/15688/4 "2018-06-14T09:39:47Z")

</div>

the way to do this within the current framework is to specify each bottle as its own ingredient.

i.e.

- bottle
- bottle
- bottle
- bottle

rather than

- bottle, 4

---

<div class="post-metadata">

**Author:** ![Zhilkin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/zhilkin/32/3749_2.png) [@Zhilkin](https://discourse.cataclysmdda.org/u/Zhilkin)\
**Post date:** [June 14, 2018, 10:21am UTC](https://discourse.cataclysmdda.org/t/more-flexible-recipe/15688/5 "2018-06-14T10:21:04Z")

</div>

I guess you can use requirements for that:

```json
  {
    "id": "leather_large",
    "type": "requirement",
    "//": "Leather or leather equivalent items for crafting.",
    "components": [[ [ "leather", 6], ["tanned_hide", 1] ] ]
  },

```

More here:

> <https://github.com/CleverRaven/Cataclysm-DDA/pull/21892>

---

<div class="post-metadata">

**Author:** ![Zhilkin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/zhilkin/32/3749_2.png) [@Zhilkin](https://discourse.cataclysmdda.org/u/Zhilkin)\
**Post date:** [June 14, 2018, 10:28am UTC](https://discourse.cataclysmdda.org/t/more-flexible-recipe/15688/6 "2018-06-14T10:28:02Z")

</div>

> [@mlangsdorf](#):
>
> I thought someone had written a pull request for this, but I can’t find it at github right now.

Is this it?

> <https://github.com/CleverRaven/Cataclysm-DDA/pull/17435>
>
> Includes #17434
> 
> Currently a bit hacky due to a type id "cast" that is removed a…t finalization.
> 
> Allows extracting crafting components and tools to a non-inlined requirement.
> As an example, I modified the granola recipe to use a new "fruit\_sweet" requirement instead of a long list of sweet fruit.
> 
> Supports multiplication of requirements.
> 
> Currently only supports inlining the requirements in the last array of the vector. That is, it only allows alternative components.
> For example, you can list a list of fruits to use in granola, have alternative bread types for sandwich, but can't have one inlined requirement contain both "any kind of bread" and "butter or peanut butter" - the recipe would need to list those two separately.

---

<div class="post-metadata">

**Author:** ![mlangsdorf](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/mlangsdorf/32/2462_2.png) [@mlangsdorf](https://discourse.cataclysmdda.org/u/mlangsdorf)\
**Post date:** [June 14, 2018, 10:55am UTC](https://discourse.cataclysmdda.org/t/more-flexible-recipe/15688/7 "2018-06-14T10:55:59Z")

</div>

Thanks, Zhilkin, those were some of the ones I was thinking of.

I might pick up the requirements one. It looks like its a json only change and should be relatively easy to do.

---

<div class="post-metadata">

**Author:** ![Podesta](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/podesta/32/2524_2.png) [@Podesta](https://discourse.cataclysmdda.org/u/Podesta)\
**Post date:** [June 14, 2018, 12:32pm UTC](https://discourse.cataclysmdda.org/t/more-flexible-recipe/15688/8 "2018-06-14T12:32:37Z")

</div>

Would the requirements work in this way? You would still need all the ingredients of the same kind, no? If it was `"components": [[ [ "leather", 12], ["tanned_hide", 2] ] ]` you still wouldn’t be able to use 6 leathers and 1 tanned hide, right?

I feel like the move to the requirements is still pretty good, as it’ll definitely make it much easier and possible to have consistent recipes across the board.

---

<div class="post-metadata">

**Author:** ![mlangsdorf](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/mlangsdorf/32/2462_2.png) [@mlangsdorf](https://discourse.cataclysmdda.org/u/mlangsdorf)\
**Post date:** [June 14, 2018, 5:01pm UTC](https://discourse.cataclysmdda.org/t/more-flexible-recipe/15688/9 "2018-06-14T17:01:58Z")

</div>

Right, moving to requirements isn’t enough, but it will make it easier in the future to create recipes that use mixed ingredients properly.

I may get distracted, because as one of the reviewers notes, the current handling of tanned hides and pelts is awful and they all need to be replaced by a smarter ingredients parse that knows each hide/pelt is potentially 8 leathers/furs and asks you if you want to cut stuff up to reach the count. I’m not sure if C:DDA already has most the tools to enable that or not.

---

<div class="post-metadata">

**Author:** ![Zhilkin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/zhilkin/32/3749_2.png) [@Zhilkin](https://discourse.cataclysmdda.org/u/Zhilkin)\
**Post date:** [June 14, 2018, 7:17pm UTC](https://discourse.cataclysmdda.org/t/more-flexible-recipe/15688/10 "2018-06-14T19:17:42Z")

</div>

You cannot mix components - I’ve already stumbled upon this here:

> <https://github.com/CleverRaven/Cataclysm-DDA/pull/20569>
