I'm trying to add a resistance type "ne_fire" if the current entity already had the resistance type "fire".
I was able to accomplish that, by using the below code:
Code: Select all
for i = 1, ent_count do
--- Add the same amount of "ne_fire" Resistances as the current "fire" Resistances
for _, ent_type in pairs(data.raw[entity_types_list[i]]) do
if ent_type.resistances then
for _, r_type in pairs(ent_type.resistances) do
if r_type.type == "fire" and r_type.percent then
table.insert(ent_type.resistances, {type = "ne_fire", percent = r_type.percent})
end
end
end
end
end
So in the below example, I added 50% "ne_fire", though the entity already had it.
Code: Select all
data.raw["unit-spawner"]["ne-spawner-pink"].resistances[3].type = "fire"
data.raw["unit-spawner"]["ne-spawner-pink"].resistances[3].decrease = 5
data.raw["unit-spawner"]["ne-spawner-pink"].resistances[3].percent = 50
data.raw["unit-spawner"]["ne-spawner-pink"].resistances[4].type = "ne_fire"
data.raw["unit-spawner"]["ne-spawner-pink"].resistances[4].percent = 100
data.raw["unit-spawner"]["ne-spawner-pink"].resistances[5].type = "ne_fire"
data.raw["unit-spawner"]["ne-spawner-pink"].resistances[5].percent = 50
Not sure how to add this check in my code.
Thanks.