The definition of util.tech_remove_prerequisites
does appear to be this in this mod:
function util.tech_remove_prerequisites (prototype_name, prerequisites)
local prototype = data.raw.technology[prototype_name]
if not prototype then return end
for _, new_prerequisite in pairs(prerequisites) do
for _, old_prerequisite in pairs(prototype.prerequisites) do
if old_prerequisite == new_prerequisite then
prototype.prerequisites[_] = nil
end
end
end
end
Which is setting it to nil
, which in Lua does not remove the array entry and is leaving it as nil, the proper method would be to replace the prototype.prerequisites[_] = nil
line with:
table.remove(prototype.prerequisites, _)
Do note, that will shift the array indices, so if you want to check the rest of the array then you will skip the new element in that location, so you probably want to change around the rest of the loop to iterate from the last entry to the first, as right now it is iterating from the first to the last, which will check the entries with the wrong key and you can end up removing an alternative one, so I would replace that whole function with (untested code, typed up in post, but it should be close enough if not exact):
function util.tech_remove_prerequisites (prototype_name, prerequisites)
local prototype = data.raw.technology[prototype_name]
if not prototype then return end
for _, new_prerequisite in pairs(prerequisites) do
for i = #prototype.prerequisites, 1, -1 do
if prototype.prerequisites[i] == new_prerequisite then
table.remove(prototype.prerequisites, i)
end
end
end
end