This commit is contained in:
Brevven 2021-12-28 23:10:09 -08:00
parent a4e94d4337
commit b2bcded14d
3 changed files with 41 additions and 2 deletions

View file

@ -1,4 +1,9 @@
---------------------------------------------------------------------------------------------------
Version: 0.0.6
Date: 2021-12-30
Changes:
- Graphite compatibility - crucible
---------------------------------------------------------------------------------------------------
Version: 0.0.5
Date: 2021-08-20
Changes:

View file

@ -22,6 +22,13 @@ function util.get_stack_size(default)
return default
end
function util.k2assets()
if mods["Krastorio2Assets"] then
return "__Krastorio2Assets__"
end
return "__Krastorio2__/graphics"
end
-- check if a table contains a sought value
function util.contains(table, sought)
for i, value in pairs(table) do
@ -102,7 +109,7 @@ end
-- Add a given quantity of product to a given recipe.
-- Only works for recipes with multiple products
function util.add_product(recipe_name, product)
if data.raw.recipe[recipe_name] and data.raw.item[product] then
if data.raw.recipe[recipe_name] and (data.raw.item[product[1]] or data.raw.item[product.name]) then
add_product(data.raw.recipe[recipe_name], product)
add_product(data.raw.recipe[recipe_name].normal, product)
add_product(data.raw.recipe[recipe_name].expensive, product)
@ -267,6 +274,31 @@ function has_ingredient(recipe, ingredient)
return false
end
-- Remove a product from a recipe, WILL NOT remove the only product
function util.remove_product(recipe_name, old)
if me.bypass[recipe_name] then return end
if data.raw.recipe[recipe_name] then
remove_product(data.raw.recipe[recipe_name], old)
remove_product(data.raw.recipe[recipe_name].normal, old)
remove_product(data.raw.recipe[recipe_name].expensive, old)
end
end
function remove_product(recipe, old)
index = -1
if recipe ~= nil and recipe.results ~= nil then
for i, result in pairs(recipe.results) do
if result.name == old or result[1] == old then
index = i
break
end
end
if index > -1 then
table.remove(recipe.results, index)
end
end
end
-- Replace one product with another in a recipe
function util.replace_product(recipe_name, old, new)
if data.raw.recipe[recipe_name] then

View file

@ -8,10 +8,12 @@ util.add_prerequisite("steel-processing", "foundry")
util.set_to_founding("tungsten-carbide")
util.add_ingredient("tungsten-carbide", util.me.carbon(), 1)
util.set_to_founding("silicon")
util.add_ingredient("silicon", util.me.carbon(), 1)
util.set_to_founding("cermet")
util.set_to_founding("cermet") -- from zirconium
util.set_to_founding("crucible") -- from graphite
-- K2
for i, machine in pairs(util.me.get_other_machines()) do