Module:Navboxes

Revision as of 10:23, 8 June 2021 by Inconvenient (talk | contribs) (Created module to separate navbox generators and avoid potentially breaking existing code)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Navboxes/doc

-- New module to stop navbox generators cluttering other modules

local p = {}

local ItemData = mw.loadData('Module:Items/data')

local Shared = require('Module:Shared')
local Icons = require('Module:Icons')

function p.getSkillcapeNavbox(frame)
  local capeList = {}
  for i, item in pairs(ItemData.Items) do
    if Shared.contains(item.name, 'Skillcape') or item.name == 'Cape of Completion' then
    table.insert(capeList, Icons.Icon({item.name, type='item'}))
    end
  end
  local result = '{| class="wikitable" style="margin:auto; clear:both; width: 100%"'
  result = result..'\r\n!'..Icons.Icon({'Cape of Completion', 'Skillcapes', type='item'})
  result = result..'\r\n|'..table.concat(capeList, ' • ')
  result = result..'\r\n|}'
  return result
end

return p