Skip to content

Commit a4d0772

Browse files
committed
Fixing override functions
1 parent 81bda26 commit a4d0772

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

angelsrefining/prototypes/override-functions.lua

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ ov_functions.set_research_difficulty = function(technology, unit_time, unit_amou
546546
log("technology " .. technology .. " does not have an unlock condition")
547547
end
548548
end
549-
if trigger == "unit" or nil then
549+
if trigger == nil or trigger == "unit" then
550550
modify_table.technologies[technology].difficulty = tab_form["unit"]
551551
else
552552
modify_table.technologies[technology].difficulty = tab_form[trigger]
@@ -765,8 +765,10 @@ local function adjust_recipe(recipe) -- check a recipe for basic adjustments bas
765765
end
766766
elseif recipe.additional_categories then
767767
for i, category in pairs(recipe.additional_categories) do
768-
table.remove(recipe.additional_categories, i)
769-
break
768+
if category == category_name then
769+
table.remove(recipe.additional_categories, i)
770+
break
771+
end
770772
end
771773
end
772774
end
@@ -840,7 +842,15 @@ local function adjust_technology(tech, tech_name) -- check a tech for basic adju
840842
for pk, prereq in pairs(tech.prerequisites) do
841843
local new = substitution_table.technologies[prereq]
842844
if new then
843-
tech.prerequisites[pk] = new
845+
if dup_table[new] then
846+
-- new prerequisite already exists; remove this entry instead of duplicating
847+
to_remove[pk] = true
848+
else
849+
tech.prerequisites[pk] = new
850+
dup_table[new] = true
851+
end
852+
else
853+
dup_table[prereq] = true
844854
end
845855
if modifications and modifications[prereq] == false then
846856
to_remove[pk] = true
@@ -850,8 +860,6 @@ local function adjust_technology(tech, tech_name) -- check a tech for basic adju
850860
for pk, prereq in pairs(tech.prerequisites) do
851861
if to_remove[pk] then
852862
table.insert(actual_remove, pk)
853-
else
854-
dup_table[tech.prerequisites[pk]] = true
855863
end
856864
end
857865
for i = #actual_remove, 1, -1 do
@@ -871,7 +879,7 @@ local function adjust_technology(tech, tech_name) -- check a tech for basic adju
871879
local overrides = override_table.technologies[tech_name]
872880
if overrides then
873881
if type(overrides) == "string" then
874-
tech[overrides] = not tech[overrides] or true
882+
tech[overrides] = not tech[overrides]
875883
else
876884
override_subtable(tech, overrides)
877885
end

0 commit comments

Comments
 (0)