Page 1 of 2

[0.17.14] Recipes with more than one instance of the same ingredient

Posted: Sat Mar 16, 2019 7:32 pm
by GotLag
In the process of testing a mod I ended up with a recipe containing the following ingredients:

Code: Select all

    ingredients =
    {
      {"copper-cable", 5},
      {"electronic-circuit", 2},
      {"copper-cable", 1},
      {"copper-cable", 1}
    }
In-game this shows up in tooltips and assemblers as having four separate ingredients: 5x copper cable, 1x copper cable, 1x copper cable and 2x electronic circuit.
Inserters only place copper cable in the first slot (5x) in an assembler and leave the other two slots empty, so nothing is crafted.

Inserters probably shouldn't have to have logic added to check for this, and should this sort of recipe definition even be allowed?
However, I can imagine it's possible someone might want multiple slots for the same fluid input, for example they might have some kind of building they want to require having water pumped into from both sides, for whatever reason.

Edit: added an image:
Image

Re: [0.17.14] Recipes with more than one instance of the same ingredient

Posted: Sat Mar 16, 2019 7:39 pm
by tehfreek
I'm comfortable with leaving this as Undefined Behavior, i.e. "stop hitting yourself".

Re: [0.17.14] Recipes with more than one instance of the same ingredient

Posted: Sat Mar 16, 2019 7:41 pm
by GotLag
Yeah I'm not aching to see this fixed somehow, but I feel it's an odd behaviour that the devs should at least be aware of (if they're not already).

Re: [0.17.14] Recipes with more than one instance of the same ingredient

Posted: Sat Mar 16, 2019 7:44 pm
by dog80
tehfreek wrote: Sat Mar 16, 2019 7:39 pm I'm comfortable with leaving this as Undefined Behavior, i.e. "stop hitting yourself".
dx

Re: [0.17.14] Recipes with more than one instance of the same ingredient

Posted: Sat Mar 16, 2019 8:23 pm
by Rseding91
Thanks for the report. I can either ignore it or enforce that there aren't duplicates in recipe inputs. There's no need for duplicate recipe inputs since a single input stack is allows to exceed the input stack limits (assuming the item itself won't crash the game if stacked > 1).

Re: [0.17.14] Recipes with more than one instance of the same ingredient

Posted: Sat Mar 16, 2019 9:16 pm
by kovarex
I vote for never allowing duplicate inputs and checking it on prototype load.

Re: [0.17.14] Recipes with more than one instance of the same ingredient

Posted: Sun Mar 17, 2019 2:48 am
by GotLag
I was really tired when I posted this, or I would have thought of another possibility: if a recipe has multiple entries for a single item type, consolidate them into a single entry. So the recipe in my first post would become:

Code: Select all

    ingredients =
    {
      {"copper-cable", 7},
      {"electronic-circuit", 2}
    }

Re: [0.17.14] Recipes with more than one instance of the same ingredient

Posted: Sun Mar 17, 2019 3:53 am
by coderpatsy
If they don't just ignore it, I think it's better to just error out and let the mod maker decide if they want to sum the duplicates or just keep one.

Re: [0.17.14] Recipes with more than one instance of the same ingredient

Posted: Thu Apr 04, 2019 6:50 pm
by robot256
Yeah, the only way this should matter is if a mod is modifying recipes to add ingredients. There is no reason not to require them to search and consolidate with existing ingredients entries when they do it, since it's always during game loading and won't impact gameplay performance.

Re: [0.17.14] Recipes with more than one instance of the same ingredient

Posted: Thu Apr 04, 2019 7:23 pm
by TRauMa
This breaks Angel's Bio processing. He uses recipes where you use a temperate garden (rare item found as tree entity on the map) and get one garden back, plus a some % chance for another. Changing that to a 51% chance to get two gardens would have the same expected yield, but it wouldn't be the same because you had a real chance of ending up without the item at all, and it might not be replaceable.

So I agree that the change makes sense for inputs, but not necessarily for outputs, too. Are there any bugs with multiple same outputs? Or maybe you could add an exception in the check to allow two same item outputs if exactly one of them has a probability?

Re: [0.17.14] Recipes with more than one instance of the same ingredient

Posted: Thu Apr 04, 2019 7:49 pm
by Rseding91
TRauMa wrote: Thu Apr 04, 2019 7:23 pm This breaks Angel's Bio processing. He uses recipes where you use a temperate garden (rare item found as tree entity on the map) and get one garden back, plus a some % chance for another. Changing that to a 51% chance to get two gardens would have the same expected yield, but it wouldn't be the same because you had a real chance of ending up without the item at all, and it might not be replaceable.

So I agree that the change makes sense for inputs, but not necessarily for outputs, too. Are there any bugs with multiple same outputs? Or maybe you could add an exception in the check to allow two same item outputs if exactly one of them has a probability?
I'll just remove the check for products for the next version of 0.17. I wasn't sure on the check for ingredients in the first place - since there are so many weird cases that stuff like these checks can break. So, I don't mind not having it for products until some future time when someone finds an issue with it.

Re: [0.17.14] Recipes with more than one instance of the same ingredient

Posted: Thu Apr 04, 2019 8:25 pm
by Arch666Angel
Rseding91 wrote: Thu Apr 04, 2019 7:49 pm
TRauMa wrote: Thu Apr 04, 2019 7:23 pm This breaks Angel's Bio processing. He uses recipes where you use a temperate garden (rare item found as tree entity on the map) and get one garden back, plus a some % chance for another. Changing that to a 51% chance to get two gardens would have the same expected yield, but it wouldn't be the same because you had a real chance of ending up without the item at all, and it might not be replaceable.

So I agree that the change makes sense for inputs, but not necessarily for outputs, too. Are there any bugs with multiple same outputs? Or maybe you could add an exception in the check to allow two same item outputs if exactly one of them has a probability?
I'll just remove the check for products for the next version of 0.17. I wasn't sure on the check for ingredients in the first place - since there are so many weird cases that stuff like these checks can break. So, I don't mind not having it for products until some future time when someone finds an issue with it.
Well I wouldn't mind if you implement other options to model cases like the one mentioned by Trauma. There have been multiple suggestions over time what could be added to recipe outputs in regards to probability and products. But anyway thanks for the fix.

Re: [0.17.14] Recipes with more than one instance of the same ingredient

Posted: Fri Apr 05, 2019 4:23 am
by DRY411S
Has this fix also stopped there being duplicate results in recipes? My Recycling Machines Mod has broken in 0.17.25.

Image

I believe that it's not possible for an assembler to produce more than 1 stack of anything. Therefore when recycling anything that is made with more than 1 stack of any ingredient, the Recycling Machines produce the relevant number of stacks as output.

For example, when recycling Power Armor Mk2 [which includes 30 (3 stacks of 10) low density structures], the mod produces this recipe:

Code: Select all

  ["dry411srev-power-armor-mk2"] = {
    category = "recycling-1",
    enabled = false,
    energy_required = 25,
    group = "dry411srev-combat",
    hidden = false,
    icon = "__base__/graphics/icons/power-armor-mk2.png",
    icon_size = 32,
    ingredients = {
      {
        "power-armor-mk2",
        1
      }
    },
    localised_name = {
      "recipe-name.recycledparts",
      {
        "item-name.power-armor-mk2"
      }
    },
    name = "dry411srev-power-armor-mk2",
    order = "e[power-armor-mk2]",
    results = {
      {
        "effectivity-module-2",
        25
      },
      {
        "speed-module-2",
        25
      },
      {
        "processing-unit",
        60
      },
      {
        "electric-engine-unit",
        40
      },
      {
        "low-density-structure",
        10
      },
      {
        "low-density-structure",
        10
      },
      {
        "low-density-structure",
        10
      }
    },
    subgroup = "dry411srev-armor",
    type = "recipe"
  },
3 stacks of low density structures.

Note though that these are RESULTS not ingredients.
Rseding91 wrote: Thu Apr 04, 2019 7:49 pm I'll just remove the check for products for the next version of 0.17. I wasn't sure on the check for ingredients in the first place - since there are so many weird cases that stuff like these checks can break. So, I don't mind not having it for products until some future time when someone finds an issue with it.
Good news thanks. Didn't spot that when I posted yesterday. As highlighted by me and others, there are already issues for some mods if you DO have the limitation on products.

Re: [0.17.14] Recipes with more than one instance of the same ingredient

Posted: Fri Apr 05, 2019 1:34 pm
by AriatCowboy
Arch666Angel wrote: Thu Apr 04, 2019 8:25 pm
Rseding91 wrote: Thu Apr 04, 2019 7:49 pm
TRauMa wrote: Thu Apr 04, 2019 7:23 pm This breaks Angel's Bio processing. He uses recipes where you use a temperate garden (rare item found as tree entity on the map) and get one garden back, plus a some % chance for another. Changing that to a 51% chance to get two gardens would have the same expected yield, but it wouldn't be the same because you had a real chance of ending up without the item at all, and it might not be replaceable.

So I agree that the change makes sense for inputs, but not necessarily for outputs, too. Are there any bugs with multiple same outputs? Or maybe you could add an exception in the check to allow two same item outputs if exactly one of them has a probability?
I'll just remove the check for products for the next version of 0.17. I wasn't sure on the check for ingredients in the first place - since there are so many weird cases that stuff like these checks can break. So, I don't mind not having it for products until some future time when someone finds an issue with it.
Well I wouldn't mind if you implement other options to model cases like the one mentioned by Trauma. There have been multiple suggestions over time what could be added to recipe outputs in regards to probability and products. But anyway thanks for the fix.
I second this, that would be nice.

Re: [0.17.14] Recipes with more than one instance of the same ingredient

Posted: Fri Apr 05, 2019 3:14 pm
by nuhll
Please update? I cant play with newest version :(

Allow duplicates...

Re: [0.17.14] Recipes with more than one instance of the same ingredient

Posted: Fri Apr 05, 2019 4:26 pm
by EmperorZelos
The input one might make sense but for output, we NEED to be able to have duplicates to make certain features work nicely and there you don't need a check in the same way, it is just grab what ever is in the slot and shove it out!

Re: [0.17.14] Recipes with more than one instance of the same ingredient

Posted: Fri Apr 05, 2019 4:43 pm
by DiegoPro77
EmperorZelos wrote: Fri Apr 05, 2019 4:26 pm The input one might make sense but for output, we NEED to be able to have duplicates to make certain features work nicely and there you don't need a check in the same way, it is just grab what ever is in the slot and shove it out!
Yeah, he's right, this feature makes sense in the input (also for make order in a game that can easily become chaotic), but in the output it's needed for run many features of many mods.

For example, one of my mods uses a recipe like this:

Code: Select all

  {
    type = "recipe",
    name = name,
	(other things needed for a recipe)
    ingredients =
    {
      {"ingredient", 10},
    },
    results =
    {
      {
        name = "result",
        amount = a particular amount that you're sure to obtain
      },
	  
      {
        name = "result",
	probability = 0.5,
        amount = the probability to obtain a bigger amount than the normal
      },
	},  
  }
  

Re: [0.17.14] Recipes with more than one instance of the same ingredient

Posted: Fri Apr 05, 2019 4:50 pm
by Bilka
Rseding already said that duplicate products will be allowed again in the next version.

Re: [0.17.14] Recipes with more than one instance of the same ingredient

Posted: Fri Apr 05, 2019 7:31 pm
by DRY411S
Bilka wrote: Fri Apr 05, 2019 4:50 pm Rseding already said that duplicate products will be allowed again in the next version.
Reading also said it might be reimplemented if there are issues in the future. So I guess a few of us are wading in to say that there are issues NOW for mods BECAUSE it's been implemented. 8-)

Re: [0.17.14] Recipes with more than one instance of the same ingredient

Posted: Sat Apr 06, 2019 11:03 am
by nuhll
Bilka wrote: Fri Apr 05, 2019 4:50 pm Rseding already said that duplicate products will be allowed again in the next version.
I really dont want to stress or anything.

But with this change my whole mod pack is not working anymore, i need to disable bio processing and other mods relay on it.

Cant you push a quick update to correct this? :roll: