Module:Resistances
From Exiled Kingdoms Wiki
local p = {} resnm = {'Fire', 'Cold', 'Shock', 'Death', 'Toxic', 'Spirit'}
RawRes = mw.getCurrentFrame().args[1]
local function getIndex(tbl, findind)
for k, v in pairs(tbl) do if v == findind then return k end end return nil
end
function p.Disp()
todisp = RawRess = mw.text.split(RawRes,',',true) for key,value in ipairs(RawRess) do if (tonumber(value) > 0) then if (todisp == ) then todisp = string.format("File:%s.png %s ",
resnm[key], resnm[key], value)
else todisp = string.format("%s File:%s.png %s ", todisp,
resnm[key], resnm[key], value)
end end end return todisp
end
function p.Vuln()
vto = mw.getCurrentFrame().args[2] vval = mw.getCurrentFrame().args[3] gtles = mw.getCurrentFrame().args[4] RawRess = mw.text.split(RawRes,',',true) if (vval == nil) then vval = 0 end if (gtles == nil or gtles == ) then gtles = 'gt' end isvuln = 0 vnum = RawRess[getIndex(resnm,vto)] if (gtles == 'gt') then if (tonumber(vnum) > tonumber(vval)) then isvuln = 1 end elseif (gtles == 'lt') then if (tonumber(vnum) < tonumber(vval)) then isvuln = 1 end elseif (gtles == 'eq') then if (tonumber(vnum) == tonumber(vval)) then isvuln = 1 end elseif (gtles == 'ge') then if (tonumber(vnum) >= tonumber(vval)) then isvuln = 1 end elseif (gtles == 'le') then if (tonumber(vnum) <= tonumber(vval)) then isvuln = 1 end end return isvuln
end
return p