Page 1 of 1

How to give probabilities to recipes

Posted: Mon Dec 04, 2023 5:39 pm
by TornBreeze
Hi.

I wanted to write a little mod for myself (and maybe even for the mod portal) that adds a recipe that has no guarantee of output. Now the problem is that I can't find a working example anywhere on the internet. I don't know Lua. That's why I have to see everything once or use it (several times) to understand it.
I would be happy if someone could tell me what I have to do for this.

Here is the code I have so far. (Which unfortunately doesn't work)

Code: Select all

  
  {
    type = "recipe",
    name = "meaty chunks synthesis",
    category = "crafting-with-fluid",
    energy_required = 60,
    enabled = true,
    ingredients =
    {
    {"wood", 10},
    {type="fluid", name="steam", amount=50}
    },
    results = 
    {
    {type="item", name="meaty-chunks", probability=0.5, amount=1}
    },
    result = "meaty-chunks"
  },
Thank you in advance.

Re: How to give probabilities to recipes

Posted: Mon Dec 04, 2023 5:51 pm
by Qon
TornBreeze wrote:
Mon Dec 04, 2023 5:39 pm
(Which unfortunately doesn't work)
If you are trying to be as vague as possible, you are very close to achieving perfection.
That is not a good strategy if you are looking for help though.

Beyond that, your code obviously doesn't work, because meaty-chunks do not exist in the base game and the code you provided doesn't add them.
Also, I don't see you extending data with this table either, it's not a complete mod or you forgot to actually provide your prototypes to the game.
Are you trying to keep your code you want help with secret as well?
And why do you have both "results" and "result"? That seems fishy to me but I'm not going to look up the documentation and verify that this might be an issue if you can't upload your complete mod for me to test. So maybe look up the documentation for recipe prototypes and see what you are doing wrong?

Re: How to give probabilities to recipes

Posted: Mon Dec 04, 2023 6:35 pm
by TornBreeze
OK. Apparently the problem was actually present in the Result and Results code. Thanks for that. Absolutely missed that. By the way, I don't really care about the code since I'm primarily making the mod for myself anyway. I just didn't include the rest because I didn't want to make it confusing. Thanks anyway for your fast reply.

Re: How to give probabilities to recipes

Posted: Wed Dec 06, 2023 2:27 pm
by starpuppy
I wish you luck with your modding endeavor~! Looks interesting!!

Re: How to give probabilities to recipes

Posted: Thu Dec 07, 2023 6:32 am
by vjbone

Code: Select all

{
    type = "recipe",
    name = "uranium-processing",
    energy_required = 12,
    enabled = false,
    category = "centrifuging",
    ingredients = {{"uranium-ore", 10}},
    icon = "__base__/graphics/icons/uranium-processing.png",
    icon_size = 64, icon_mipmaps = 4,
    subgroup = "raw-material",
    order = "k[uranium-processing]", -- k ordering so it shows up after explosives which is j ordering
    results =
    {
      {
        name = "uranium-235",
        probability = 0.007,
        amount = 1
      },
      {
        name = "uranium-238",
        probability = 0.993,
        amount = 1
      }
    }
  },
So you want something like this ^?

Code: Select all

{
    type = "item",
    name = "uranium-238",
    icon = "__base__/graphics/icons/uranium-238.png",
    icon_size = 64, icon_mipmaps = 4,
    subgroup = "intermediate-product",
    order = "r[uranium-238]",
    stack_size = 100
  },

Re: How to give probabilities to recipes

Posted: Wed Dec 20, 2023 1:13 am
by TornBreeze
Sorry that I'm just now answering.
Yes, that's exactly what I had in mind. Is that in the game files? To be honest, I didn't even look or think about it.

Re: How to give probabilities to recipes

Posted: Wed Dec 20, 2023 6:28 am
by vjbone
TornBreeze wrote:
Wed Dec 20, 2023 1:13 am
Sorry that I'm just now answering.
Yes, that's exactly what I had in mind. Is that in the game files? To be honest, I didn't even look or think about it.
Yes it's from base game. https://github.com/wube/factorio-data