@Sander_Bouwhuis , not sure this situation is really worth a table detailing flow-cases... ;)
local produced_amount = nil, safe_probability = product.probability
if safe_probability == nil then safe_probability = 1 end
if product.amount_max ~= nil and product.amount_min ~= nil then
produced_amount = ((product.amount_max + product.amount_min) / 2) * safe_probability
else
produced_amount = product.amount * safe_probability
end
... or even:
local produced_amount = product.amount, safe_probability = product.probability
if safe_probability == nil then safe_probability = 1 end
if product.amount_max ~= nil and product.amount_min ~= nil then
produced_amount = (product.amount_max + product.amount_min) / 2
end
produced_amount = produced_amount * safe_probability