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
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get the amount of the result
|
-- Get the amount of the result (currently ignores probability)
|
||||||
function util.get_amount(recipe_name, product)
|
function util.get_amount(recipe_name, product)
|
||||||
if not product then product = recipe_name end
|
if not product then product = recipe_name end
|
||||||
local recipe = data.raw.recipe[recipe_name]
|
local recipe = data.raw.recipe[recipe_name]
|
||||||
if recipe then
|
if recipe then
|
||||||
if recipe.results then
|
if recipe.results then
|
||||||
for i, result in pairs(recipe.results) do
|
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
|
||||||
end
|
end
|
||||||
return 0
|
return 0
|
||||||
|
|
@ -1019,7 +1025,7 @@ function replace_some_product(recipe, old, old_amount, new, new_amount)
|
||||||
end
|
end
|
||||||
end
|
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
|
for i, product in pairs(recipe.results) do
|
||||||
if product.name == old then
|
if product.name == old then
|
||||||
product.amount = math.max(1, product.amount - old_amount)
|
product.amount = math.max(1, product.amount - old_amount)
|
||||||
|
|
@ -1513,7 +1519,7 @@ end
|
||||||
|
|
||||||
-- Adds a result to a mineable type
|
-- Adds a result to a mineable type
|
||||||
function util.add_minable_result(t, name, result)
|
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
|
if data.raw[t][name].minable.result and not data.raw[t][name].minable.results then
|
||||||
data.raw[t][name].minable.results = {
|
data.raw[t][name].minable.results = {
|
||||||
util.item(data.raw[t][name].minable.result ,data.raw[t][name].minable.count)}
|
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
|
data.raw[t][name].minable.result_count = nil
|
||||||
end
|
end
|
||||||
if data.raw[t][name].minable.results then
|
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)
|
table.insert(data.raw[t][name].minable.results, result)
|
||||||
else
|
else
|
||||||
data.raw[t][name].minable.results = {result}
|
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
|
data.raw.recipe[recipe_name].redo_recycling = true
|
||||||
end
|
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
|
-- According to https://mods.factorio.com/mod/Asteroid_Mining, the
|
||||||
-- following function is under this MIT license (similar license, different author):
|
-- following function is under this MIT license (similar license, different author):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue