up
This commit is contained in:
parent
d89c5580f3
commit
6c7b85f515
1 changed files with 30 additions and 0 deletions
|
@ -312,6 +312,21 @@ function util.add_unlock(technology_name, recipe)
|
||||||
util.add_effect(technology_name, {type="unlock-recipe", recipe=recipe})
|
util.add_effect(technology_name, {type="unlock-recipe", recipe=recipe})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Check if a tech unlocks a recipe
|
||||||
|
function util.check_unlock(technology_name, recipe)
|
||||||
|
local technology = data.raw.technology[technology_name]
|
||||||
|
if technology and technology.effects then
|
||||||
|
for i, effect in pairs(technology.effects) do
|
||||||
|
if effect.type == "unlock-recipe" and effect.recipe == recipe_name then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- remove recipe unlock effect from a given technology, multiple times if necessary
|
-- remove recipe unlock effect from a given technology, multiple times if necessary
|
||||||
function util.remove_recipe_effect(technology_name, recipe_name)
|
function util.remove_recipe_effect(technology_name, recipe_name)
|
||||||
local technology = data.raw.technology[technology_name]
|
local technology = data.raw.technology[technology_name]
|
||||||
|
@ -531,6 +546,21 @@ function util.get_amount(recipe_name, product)
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Get the count of results
|
||||||
|
function util.get_result_count(recipe_name, product)
|
||||||
|
if not product then product = recipe_name end
|
||||||
|
local recipe = data.raw.recipe[recipe_name]
|
||||||
|
if recipe then
|
||||||
|
if recipe.normal and recipe.normal.results then
|
||||||
|
return #(recipe.normal.results)
|
||||||
|
elseif recipe.results then
|
||||||
|
return #(recipe.results)
|
||||||
|
end
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
-- Replace one ingredient with another in a recipe
|
-- Replace one ingredient with another in a recipe
|
||||||
-- Use amount to set an amount. If that amount is a multiplier instead of an exact amount, set multiply true.
|
-- Use amount to set an amount. If that amount is a multiplier instead of an exact amount, set multiply true.
|
||||||
function util.replace_ingredient(recipe_name, old, new, amount, multiply, options)
|
function util.replace_ingredient(recipe_name, old, new, amount, multiply, options)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue