FANDOM


local p = {}
local typeX  = mw.loadData('Module:type/name')
 
--make singular
function p.sg (x)
   if x ~= nil then
      if string.sub(x, -1) == "s" then
         return string.sub(x, 1, -2)
      else
         return x
      end
   end
end
 
--gets type from [[Module:type/name]]
function p.GetTypeX(x)
   if x ~= nil then
      return typeX[string.lower(x)]
   end
end
 
 
--gets image from [[Module:type/image]]
function p.GetImage(arg)
   local imageX = mw.loadData('Module:type/image')
   if arg ~= nil then
      return imageX[string.lower(arg)]
   end
end
 
--creates an image link
function p.CreateImageLink(image, link, size)
   if size ~= nil then
      size = "|"..size
   else
      size = ""
   end
   return "[[File:"..image..size.."|link=:Category:"..link.."]]"
end
 
 
-- ItemCard creates an image linking to the category based on the type and the name
-- used in [[Template:Item_Card]]
function p.ItemCard(frame)
   local x = p.GetTypeX(frame.args[1]) -- type
   if x == nil then
      return nil  -- not a recognized type
   else
      local y = p.GetImage(x)
      if y == nil then      -- no image for type
         return "[[:category:"..x..'|<span style="color:white">'..p.sg(x)..'</span>]]'
      else
         return p.CreateImageLink(y, x, "20px").." ".."[[:category:"..x..'|<span style="color:white">'..p.sg(x)..'</span>]]'
      end
   end
end
 
-- ImageLink creates an image linking to the category based on the type
-- used in item pages like [[Weapons]]
function p.ItemLink(frame)
   local x = p.GetTypeX(frame.args[1]) -- type
   if x == nil then
      return frame.args[1]  -- not a recognized type
   else
      local y = p.GetImage(x)
      if y == nil then      -- no image for type
         return x
      else
         return p.CreateImageLink(y, x, "25px")
      end
   end
end
 
--gets type from [[Module:type/name]]
function p.GetType(frame)
   return typeX[string.lower(frame.args[1])]
end
 
function p.skip(frame)
   local skip =
     {
     ["currency"] = "skip",
     ["tactics"] = "skip",
     ["player tactics"] = "skip",
     ["alliance tactics"] = "skip",
     ["titles"] = "skip",
     ["food"] = "skip",
     ["drinks"] = "skip",
     ["herbs"] = "skip",
     ["medicines"] = "skip",
     ["consumables"] = "skip",
     ["sworn swords"] = "skip",
     ["chests"] = "Skip",
     }
   return skip[frame.args[1]]
end
 
function p.test(frame)
   local a = "x"
   return a
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.