Skip to content

Instantly share code, notes, and snippets.

@ClaudeMetz
Created June 20, 2019 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ClaudeMetz/df2b085814d4de51425938e8ee55eb82 to your computer and use it in GitHub Desktop.
Save ClaudeMetz/df2b085814d4de51425938e8ee55eb82 to your computer and use it in GitHub Desktop.
[Factorio Modding] How to determine the actual produced amount of a recipe product
-- This code determines the actual amount of a product that a recipe produces.
-- The variable 'product' is one of the tables you get from recipePrototype.products.
-- Handles normal, probabilistic and 'range'-recipes
local produced_amount = nil
if product.amount_max ~= nil and product.amount_min ~= nil then
produced_amount = ((product.amount_max + product.amount_min) / 2) * product.probability
elseif product.probability ~= nil then
produced_amount = product.amount * product.probability
else
produced_amount = product.amount
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment