Created
June 20, 2019 13:40
-
-
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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