How to give probabilities to recipes

Place to get help with not working mods / modding interface.
Post Reply
User avatar
TornBreeze
Burner Inserter
Burner Inserter
Posts: 8
Joined: Tue Jul 31, 2018 12:55 pm
Contact:

How to give probabilities to recipes

Post 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.
"Ein häufiger Fehler, den Leute
machen, wenn sie etwas völlig
Idiotensicheres erfinden wollen,
ist den Einfallsreichtum von
Vollidioten zu unterschätzen."
- Douglas Adams

Qon
Smart Inserter
Smart Inserter
Posts: 2118
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: How to give probabilities to recipes

Post 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?

User avatar
TornBreeze
Burner Inserter
Burner Inserter
Posts: 8
Joined: Tue Jul 31, 2018 12:55 pm
Contact:

Re: How to give probabilities to recipes

Post 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.
"Ein häufiger Fehler, den Leute
machen, wenn sie etwas völlig
Idiotensicheres erfinden wollen,
ist den Einfallsreichtum von
Vollidioten zu unterschätzen."
- Douglas Adams

starpuppy
Manual Inserter
Manual Inserter
Posts: 4
Joined: Thu Nov 30, 2023 12:51 pm
Contact:

Re: How to give probabilities to recipes

Post by starpuppy »

I wish you luck with your modding endeavor~! Looks interesting!!

vjbone
Fast Inserter
Fast Inserter
Posts: 143
Joined: Sun Feb 14, 2016 10:02 am
Contact:

Re: How to give probabilities to recipes

Post 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
  },

User avatar
TornBreeze
Burner Inserter
Burner Inserter
Posts: 8
Joined: Tue Jul 31, 2018 12:55 pm
Contact:

Re: How to give probabilities to recipes

Post 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.
"Ein häufiger Fehler, den Leute
machen, wenn sie etwas völlig
Idiotensicheres erfinden wollen,
ist den Einfallsreichtum von
Vollidioten zu unterschätzen."
- Douglas Adams

vjbone
Fast Inserter
Fast Inserter
Posts: 143
Joined: Sun Feb 14, 2016 10:02 am
Contact:

Re: How to give probabilities to recipes

Post 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

Post Reply

Return to “Modding help”