Factorio: fix adjust_energy to hit special cases with implied energy cost
This commit is contained in:
parent
1d954b192c
commit
2d84245103
|
@ -51,20 +51,32 @@ function copy_factorio_icon(tech, tech_source)
|
||||||
tech.icon_size = table.deepcopy(technologies[tech_source].icon_size)
|
tech.icon_size = table.deepcopy(technologies[tech_source].icon_size)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
{# This got complex, but seems to be required to hit all corner cases #}
|
||||||
function adjust_energy(recipe_name, factor)
|
function adjust_energy(recipe_name, factor)
|
||||||
local recipe = data.raw.recipe[recipe_name]
|
local recipe = data.raw.recipe[recipe_name]
|
||||||
local energy = recipe.energy_required
|
local energy = recipe.energy_required
|
||||||
if (energy ~= nil) then
|
|
||||||
data.raw.recipe[recipe_name].energy_required = energy * factor
|
if (recipe.normal ~= nil) then
|
||||||
end
|
if (recipe.normal.energy_required == nil) then
|
||||||
if (recipe.normal ~= nil and recipe.normal.energy_required ~= nil) then
|
energy = 0.5
|
||||||
energy = recipe.normal.energy_required
|
else
|
||||||
|
energy = recipe.normal.energy_required
|
||||||
|
end
|
||||||
recipe.normal.energy_required = energy * factor
|
recipe.normal.energy_required = energy * factor
|
||||||
end
|
end
|
||||||
if (recipe.expensive ~= nil and recipe.expensive.energy_required ~= nil) then
|
if (recipe.expensive ~= nil) then
|
||||||
energy = recipe.expensive.energy_required
|
if (recipe.expensive.energy_required == nil) then
|
||||||
|
energy = 0.5
|
||||||
|
else
|
||||||
|
energy = recipe.expensive.energy_required
|
||||||
|
end
|
||||||
recipe.expensive.energy_required = energy * factor
|
recipe.expensive.energy_required = energy * factor
|
||||||
end
|
end
|
||||||
|
if (energy ~= nil) then
|
||||||
|
data.raw.recipe[recipe_name].energy_required = energy * factor
|
||||||
|
elseif (recipe.expensive == nil and recipe.normal == nil) then
|
||||||
|
data.raw.recipe[recipe_name].energy_required = 0.5 * factor
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
data.raw["assembling-machine"]["assembling-machine-1"].crafting_categories = table.deepcopy(data.raw["assembling-machine"]["assembling-machine-3"].crafting_categories)
|
data.raw["assembling-machine"]["assembling-machine-1"].crafting_categories = table.deepcopy(data.raw["assembling-machine"]["assembling-machine-3"].crafting_categories)
|
||||||
|
|
Loading…
Reference in New Issue