Page 1 of 1

How does product.probability work?

Posted: Thu Jun 09, 2016 7:40 pm
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?

Re: How does product.probability work?

Posted: Fri Jun 10, 2016 9:09 am
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.

Re: How does product.probability work?

Posted: Fri Jun 10, 2016 10:26 am
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

Re: How does product.probability work?

Posted: Sat Jun 11, 2016 6:34 pm
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",
  },