How does product.probability work?

Place to get help with not working mods / modding interface.
matjojo
Filter Inserter
Filter Inserter
Posts: 338
Joined: Wed Jun 17, 2015 6:08 pm
Contact:

How does product.probability work?

Post by matjojo »

This is what the lua-api says about itL
  • amount :: float (optional): Amount of the item or fluid to give. If not specified, amount_min, amount_max and probability must all be specified.
  • amount_min :: uint (optional): Minimal amount of the item or fluid to give. Has no effect when amount is specified.
  • amount_max :: uint (optional): Maximum amount of the item or fluid to give. Has no effect when amount is specified.
  • probability :: double (optional): A value in range [0, 1]. Item or fluid is only given with this probability; otherwise no product is produced. Has no effect when amount is specified.

So how would I make a recipe to have a .5 change to give just 1, not a number in between two barriers?
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: How does product.probability work?

Post by bobingabout »

Basically... set amount_min and amount_max to the same number, so if you always want 1, set both to 1, the resultant amount will be between... 1 and 1, and therefore always 1.

Though, I may have used probability on amount before, and I'm fairly use it still works. I may have used amount_min and amound_max without probability too, I can't remember.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
matjojo
Filter Inserter
Filter Inserter
Posts: 338
Joined: Wed Jun 17, 2015 6:08 pm
Contact:

Re: How does product.probability work?

Post by matjojo »

bobingabout wrote:Basically... set amount_min and amount_max to the same number, so if you always want 1, set both to 1, the resultant amount will be between... 1 and 1, and therefore always 1.

Though, I may have used probability on amount before, and I'm fairly use it still works. I may have used amount_min and amound_max without probability too, I can't remember.

alrighty then, thanks a lot
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: How does product.probability work?

Post by bobingabout »

See, I knew I'd used probability with amount and not amount_min/amount_max before, and have it work.

Code: Select all

data:extend(
{
  {
    type = "recipe",
    name = "sort-gem-ore",
    energy_required = 1,
    ingredients =
    {
	  {"gem-ore", 1},
    },
    results =
    {
      {type="item", name="ruby-ore", amount=1, probability = bobmods.gems.RubyRatio},
      {type="item", name="sapphire-ore", amount=1, probability = bobmods.gems.SapphireRatio},
      {type="item", name="emerald-ore", amount=1, probability = bobmods.gems.EmeraldRatio},
      {type="item", name="amethyst-ore", amount=1, probability = bobmods.gems.AmethystRatio},
      {type="item", name="topaz-ore", amount=1, probability = bobmods.gems.TopazRatio},
      {type="item", name="diamond-ore", amount=1, probability = bobmods.gems.DiamondRatio},
    },
    subgroup = "bob-ores",
    icon = "__bobores__/graphics/icons/gem-ore.png",
    order = "a-0",
  },
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
Post Reply

Return to “Modding help”