up
This commit is contained in:
parent
0490de093a
commit
a62c97d973
1 changed files with 22 additions and 4 deletions
|
|
@ -912,14 +912,20 @@ function util.get_ingredient_amount(recipe_name, ingredient_name)
|
|||
return 0
|
||||
end
|
||||
|
||||
-- Get the amount of the result
|
||||
-- Get the amount of the result (currently ignores probability)
|
||||
function util.get_amount(recipe_name, product)
|
||||
if not product then product = recipe_name end
|
||||
local recipe = data.raw.recipe[recipe_name]
|
||||
if recipe then
|
||||
if recipe.results then
|
||||
for i, result in pairs(recipe.results) do
|
||||
if result.name == product then return result.amount end
|
||||
if result.name == product then
|
||||
if result.amount then
|
||||
return result.amount
|
||||
elseif result.amount_min then
|
||||
return (result.amount_min + result.amount_max) / 2
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return 0
|
||||
|
|
@ -1019,7 +1025,7 @@ function replace_some_product(recipe, old, old_amount, new, new_amount)
|
|||
end
|
||||
end
|
||||
end
|
||||
add_product(recipe, {new, new_amount})
|
||||
add_product(recipe, util.item(new, new_amount))
|
||||
for i, product in pairs(recipe.results) do
|
||||
if product.name == old then
|
||||
product.amount = math.max(1, product.amount - old_amount)
|
||||
|
|
@ -1513,7 +1519,7 @@ end
|
|||
|
||||
-- Adds a result to a mineable type
|
||||
function util.add_minable_result(t, name, result)
|
||||
if data.raw[t] and data.raw[t][name] and data.raw[t][name].minable then
|
||||
if data.raw[t] and data.raw[t][name] and data.raw[t][name].minable and data.raw.item[result.name] then
|
||||
if data.raw[t][name].minable.result and not data.raw[t][name].minable.results then
|
||||
data.raw[t][name].minable.results = {
|
||||
util.item(data.raw[t][name].minable.result ,data.raw[t][name].minable.count)}
|
||||
|
|
@ -1521,6 +1527,9 @@ function util.add_minable_result(t, name, result)
|
|||
data.raw[t][name].minable.result_count = nil
|
||||
end
|
||||
if data.raw[t][name].minable.results then
|
||||
for _, other in pairs(data.raw[t][name].minable.results) do
|
||||
if other.name == result.name then return end -- don't add if already present
|
||||
end
|
||||
table.insert(data.raw[t][name].minable.results, result)
|
||||
else
|
||||
data.raw[t][name].minable.results = {result}
|
||||
|
|
@ -1768,6 +1777,15 @@ function prepare_redo_recycling(recipe_name)
|
|||
data.raw.recipe[recipe_name].redo_recycling = true
|
||||
end
|
||||
|
||||
-- Change furnace output count
|
||||
function util.set_minimum_furnace_outputs(category, count)
|
||||
for i, entity in pairs(data.raw.furnace) do
|
||||
if entity.result_inventory_size ~= nil and entity.result_inventory_size < count and util.contains(entity.crafting_categories, category) then
|
||||
entity.result_inventory_size = count
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- According to https://mods.factorio.com/mod/Asteroid_Mining, the
|
||||
-- following function is under this MIT license (similar license, different author):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue