If you want to add resistances against all damage types, try this:
local invincible = {}
for damage_type in pairs(data.raw["damage-type"]) do
-- invincible[#invincible] = {type = damage_type, percent = 100}
invincible[#invincible + 1] = {type = damage_type, percent = 100}
end
invincible[#invincible] = x
will assign x to the last element of invincible
. As the table is never extended, the last element is always the same and would take on the values of each of the damage types (when the loop is finished, invincible
will only have the value of the last element). Assigning values to #invincible + 1
, on the other hand, will extend the table by one element before assigning a value to the last element.