FANDOM


local p = {}
local typeX  = mw.loadData('Module:type/name')
local order = mw.loadData('Module:SortAdv/roworder')
 
--if nil return ""
function p.cln (x, y)
   if x == nil then
      if y ~= nil then
         return y -- default value
      else
         return ""
      end
   else
      return x
   end
end
 
 
function p.rewards(frame)
   local a = {}
   local y = ""
 
   for i=1, 20 do
 
      if frame.args["rew"..i] == "" then
         break
      elseif frame.args["rew"..i] == nil then
         break
      end
 
      if order[string.lower(frame.args["rew"..i])] ~= nil then
      -- item is in the 'order' list
         a[order[string.lower(frame.args["rew"..i])]] = p.cln(frame.args["rew"..i.."%"])
         --put % into the 'a' array
 
      else
      -- item is not in the order list
         local x = p.cln(frame.args["rew"..i])
         -- x = item
 
         x = frame:expandTemplate{title = "return/type/call", args = {x}}
         -- x = {{type}} of x
 
         x = typeX[string.lower(p.cln(x))] -- lowercase received type
         -- x = cell # for type
 
         x = string.lower(p.cln(x))
         x = p.cln(order[x],26)
         -- get the cell number or #26
 
         if a[x] ~= nil then
         -- breakline if a[x] already exists
            a[x] = a[x].."<br>"
         end
         a[x] = p.cln(a[x]).."[["..frame.args["rew"..i].."]] ("..p.cln(frame.args["rew"..i.."%"],"?")..")"
         -- a[x] gets the item info
 
      end
   end
 
   for i=1, 26 do
   -- expand a array
      y=y..[[| style="text-align: center;" |]]..p.cln(a[i])..'\n'
   end
 
   return frame:preprocess(y)
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.