Code: Select all
for key,tech in ipairs(table.deepcopy(data.raw["technology"])) do
if tech.prerequisites==nil or tech.prerequisites=={} then
tech.prerequisites={"iron-axe"}
data:extend{tech}
end
end
Code: Select all
for key,tech in ipairs(table.deepcopy(data.raw["technology"])) do
if tech.prerequisites==nil or tech.prerequisites=={} then
tech.prerequisites={"iron-axe"}
data:extend{tech}
end
end
Code: Select all
for key,tech in pairs(data.raw["technology"]) do
if tech.prerequisites==nil or tech.prerequisites=={} then
tech.prerequisites={"iron-axe"}
end
end
This does not do what you want, lua tables have identity
Code: Select all
> print({} == {})
false
This code does exactly what I was trying to do, thank you.DaveMcW wrote: ↑Mon Aug 31, 2020 10:39 pmIf you are only modifying vanilla recipes you can use data.lua with a dependency on base.Code: Select all
for key,tech in pairs(data.raw["technology"]) do if tech.prerequisites==nil or tech.prerequisites=={} then tech.prerequisites={"iron-axe"} end end
No it doesn't tech.prerequisites=={} is *always false*.PyroGamer666 wrote: ↑Mon Aug 31, 2020 11:14 pmThis code does exactly what I was trying to do, thank you.DaveMcW wrote: ↑Mon Aug 31, 2020 10:39 pmIf you are only modifying vanilla recipes you can use data.lua with a dependency on base.Code: Select all
for key,tech in pairs(data.raw["technology"]) do if tech.prerequisites==nil or tech.prerequisites=={} then tech.prerequisites={"iron-axe"} end end
Code: Select all
table.compare(tech.prerequisites,{})
#tech.prerequisites == 0
table_size(tech.prerequisites) == 0
...