update
This commit is contained in:
parent
d5b0007fe1
commit
77b53a87e7
1 changed files with 51 additions and 2 deletions
|
|
@ -77,14 +77,33 @@ function util.remove_prerequisite(technology_name, prerequisite)
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
-- Add an effect to a given technology
|
||||
function util.add_effect(technology_name, effect)
|
||||
local technology = data.raw.technology[technology_name]
|
||||
if technology then
|
||||
if not technology.effects then technology.effects = {} end
|
||||
table.insert(technology.effects, effect)
|
||||
end
|
||||
end
|
||||
|
||||
-- remove recipe unlock effect from a given technology
|
||||
function util.remove_recipe_effect(technology_name, recipe_name)
|
||||
local technology = data.raw.technology[technology_name]
|
||||
local index = -1
|
||||
if technology then
|
||||
for i, effect in pairs(technology.effects) do
|
||||
if effect.type == "unlock-recipe" and effect.recipe == recipe_name then
|
||||
index = i
|
||||
break
|
||||
end
|
||||
end
|
||||
if index > -1 then
|
||||
table.remove(technology.effects, index)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Set technology ingredients
|
||||
function util.set_tech_recipe(technology_name, ingredients)
|
||||
local technology = data.raw.technology[technology_name]
|
||||
|
|
@ -93,6 +112,37 @@ function util.set_tech_recipe(technology_name, ingredients)
|
|||
end
|
||||
end
|
||||
|
||||
function util.set_enabled(recipe_name, enabled)
|
||||
if data.raw.recipe[recipe_name] then
|
||||
if data.raw.recipe[recipe_name].normal then data.raw.recipe[recipe_name].normal.enabled = enabled end
|
||||
if data.raw.recipe[recipe_name].expensive then data.raw.recipe[recipe_name].expensive.enabled = enabled end
|
||||
if not data.raw.recipe[recipe_name].normal then data.raw.recipe[recipe_name].enabled = enabled end
|
||||
end
|
||||
end
|
||||
|
||||
-- Add a given quantity of ingredient to a given recipe
|
||||
function util.add_or_add_to_ingredient(recipe_name, ingredient, quantity)
|
||||
if me.bypass[recipe_name] then return end
|
||||
if data.raw.recipe[recipe_name] and data.raw.item[ingredient] then
|
||||
me.add_modified(recipe_name)
|
||||
add_or_add_to_ingredient(data.raw.recipe[recipe_name], ingredient, quantity)
|
||||
add_or_add_to_ingredient(data.raw.recipe[recipe_name].normal, ingredient, quantity)
|
||||
add_or_add_to_ingredient(data.raw.recipe[recipe_name].expensive, ingredient, quantity)
|
||||
end
|
||||
end
|
||||
|
||||
function add_or_add_to_ingredient(recipe, ingredient, quantity)
|
||||
if recipe ~= nil and recipe.ingredients ~= nil then
|
||||
for i, existing in pairs(recipe.ingredients) do
|
||||
if existing[1] == ingredient or existing.name == ingredient then
|
||||
add_to_ingredient(recipe, ingredient, quantity)
|
||||
return
|
||||
end
|
||||
end
|
||||
table.insert(recipe.ingredients, {ingredient, quantity})
|
||||
end
|
||||
end
|
||||
|
||||
-- Add a given quantity of ingredient to a given recipe
|
||||
function util.add_ingredient(recipe_name, ingredient, quantity)
|
||||
if me.bypass[recipe_name] then return end
|
||||
|
|
@ -115,7 +165,6 @@ function add_ingredient(recipe, ingredient, quantity)
|
|||
table.insert(recipe.ingredients, {ingredient, quantity})
|
||||
end
|
||||
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)
|
||||
|
|
@ -438,7 +487,7 @@ function add_to_ingredient(recipe, it, amount)
|
|||
return
|
||||
end
|
||||
if ingredient[1] == it then
|
||||
ingredient[2] = ingredients[2] + amount
|
||||
ingredient[2] = ingredient[2] + amount
|
||||
return
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue