I'd like to modify it to only apply the change to resistances, IF the entities current resistance is lower that the resistance % I'm trying to add.
So let's take the standard inserter as an example. If I'm trying to add Physical resistance of 10% to the inserter, but it currently has 20%, is should not add my change. If it only currently has 5%, then implement the change.
This is the current function:
Code: Select all
-- Adds a resistance of all damage types to an entity
function NE_Functions.Add_ALL_Damage_Resists(Raw,Percent)
if Raw ~= nil then
for k, v in pairs(data.raw["damage-type"]) do
local Resist = {type = v.name, percent = Percent} -- or you could use k, and not v.name
for i,d in pairs(Raw) do
if d.resistances == nil then d.resistances = {} end
table.insert(d.resistances, Resist)
end
end
end
end
Code: Select all
function NE_Functions.Add_ALL_Damage_Resists(Raw,Percent)
if Raw ~= nil then
for k, v in pairs(data.raw["damage-type"]) do
local Resist = {type = v.name, percent = Percent} -- or you could use k, and not v.name
for i,d in pairs(Raw) do
if d.resistances == nil then d.resistances = {} end
if d.resistances < Resist then
table.insert(d.resistances, Resist)
end
end
end
end
end