Module:Attributes: Difference between revisions

From Exiled Kingdoms Wiki
mNo edit summary
mNo edit summary
Line 47: Line 47:
     Arg3 = mw.getCurrentFrame().args[3]
     Arg3 = mw.getCurrentFrame().args[3]
     Arg4 = mw.getCurrentFrame().args[4]
     Arg4 = mw.getCurrentFrame().args[4]
    Arg5 = mw.getCurrentFrame().args[5]
     attribs = mw.text.split(Arg1,',',true)
     attribs = mw.text.split(Arg1,',',true)
     if (Arg3 == nil or Arg3 == '') then
     if (Arg3 == nil or Arg3 == '') then
         Arg3 = 0
         return ''
     end
     end
     if (Arg4 == nil or Arg4 == '') then
     if (Arg4 == nil or Arg4 == '') then
         Arg4 = 'gt'
         Arg4 = 0
     end
     end
    if (Arg5 == nil or Arg5 == '') then
        Arg5 = 'gt'
    end
    selval = 0
     if (Arg2 == 'a') then
     if (Arg2 == 'a') then
         if Comp.Compare(1, Arg4, Arg3) == true then
         for i, item in pairs(ArmAttr) do
             return 'it works'
            if (string.lower(item) == string.lower(Arg3)) then
                selval = attribs[i]
                break
             end
         end
         end
     elseif (Arg2 == 'w') then
     elseif (Arg2 == 'w') then
          
         for i, item in pairs(WpnAttr) do
            if (string.lower(item) == string.lower(Arg3)) then
                selval = attribs[i]
                break
            end
        end
    end
    if (Comp.Compare(selval, Arg5, Arg4) == true) then
        hasattr = true
     end
     end
     return hasattr
     return hasattr

Revision as of 19:52, 7 June 2017

p = {} local Comp = require( "Module:ValComp" ) Arg1 = mw.getCurrentFrame().args[1] Arg2 = mw.getCurrentFrame().args[2]

ArmAttr = {'Detection', 'Gossip', 'Stability', 'Stun Immunity', 'Tinkering', 'Wisdom', 'Shield'}

WpnAttr = {'Beast Slayer', 'Holy', 'Orc Slayer', 'Paralysis', 'Silver', 'Slow', 'Stun', 'Vicious'}

function p.Disp()

   txtout = 
   attribs = mw.text.split(Arg1,',',true)
   if (Arg2 == 'a') then
       for i, attr in pairs(attribs) do
           if (tonumber(attr) > 0) then
               if (txtout ~= ) then
                   if (i == 3 or i == 4 or i == 7) then
                       txtout = string.format('%s; %s', txtout, ArmAttr[i])
                   else
                       txtout = string.format('%s; %s %s', txtout, ArmAttr[i], attr)
                   end
               else
                   txtout = string.format('%s %s',ArmAttr[i], attr)
               end
           end
       end
   elseif (Arg2 == 'w') then
       for i, attr in pairs(attribs) do
           if (tonumber(attr) > 0) then
               if (txtout ~= ) then
                   if (i == 4 or i == 5 or i == 6 or i == 7) then
                       txtout = string.format('%s; %s', txtout, WpnAttr[i])
                   else
                       txtout = string.format('%s; %s %s', txtout, WpnAttr[i], attr)
                   end
               else
                   txtout = string.format('%s %s',WpnAttr[i], attr)
               end
           end
       end
   end
   return txtout

end

function p.Sel()

   hasattr = 0
   Arg3 = mw.getCurrentFrame().args[3]
   Arg4 = mw.getCurrentFrame().args[4]
   Arg5 = mw.getCurrentFrame().args[5]
   attribs = mw.text.split(Arg1,',',true)
   if (Arg3 == nil or Arg3 == ) then
       return 
   end
   if (Arg4 == nil or Arg4 == ) then
       Arg4 = 0
   end
   if (Arg5 == nil or Arg5 == ) then
       Arg5 = 'gt'
   end
   selval = 0
   if (Arg2 == 'a') then
       for i, item in pairs(ArmAttr) do
           if (string.lower(item) == string.lower(Arg3)) then
               selval = attribs[i]
               break
           end
       end
   elseif (Arg2 == 'w') then
       for i, item in pairs(WpnAttr) do
           if (string.lower(item) == string.lower(Arg3)) then
               selval = attribs[i]
               break
           end
       end
   end
   if (Comp.Compare(selval, Arg5, Arg4) == true) then
       hasattr = true
   end
   return hasattr

end

return p