Module:Resistances: Difference between revisions

From Exiled Kingdoms Wiki
mNo edit summary
mNo edit summary
Line 26: Line 26:
     vto = mw.getCurrentFrame().args[2]
     vto = mw.getCurrentFrame().args[2]
     vval = mw.getCurrentFrame().args[3]
     vval = mw.getCurrentFrame().args[3]
    if (vval == nil) then
        vval = 0
    end
     gtles = mw.getCurrentFrame().args[4]
     gtles = mw.getCurrentFrame().args[4]
     isvuln = 0
     isvuln = 0

Revision as of 00:39, 7 June 2017

local p = {} resnm = {'Fire', 'Cold', 'Shock', 'Death', 'Toxic', 'Spirit'}

function p.Disp()

   todisp = 
   RawRes = mw.getCurrentFrame().args[1]
   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()

   RawRes = mw.getCurrentFrame().args[1]
   RawRess = mw.text.split(RawRes,',',true)
   vto = mw.getCurrentFrame().args[2]
   vval = mw.getCurrentFrame().args[3]
   if (vval == nil) then
       vval = 0
   end
   gtles = mw.getCurrentFrame().args[4]
   isvuln = 0
   vnum = RawRess[resnm[vto]]
   if ( vnum > vval) then
       isvuln = 1
   end
   return isvuln

end

return p