Module:Skills: Difference between revisions

getThievingNavbox: Moved from Module:Navboxes
(getThievingNavbox: Order NPCs based on level requirement)
(getThievingNavbox: Moved from Module:Navboxes)
Line 6: Line 6:
--Module:Skills/Gathering for Mining, Fishing, Woodcutting
--Module:Skills/Gathering for Mining, Fishing, Woodcutting
--Module:Skills/Artisan for Smithing, Cooking, Herblore, etc.
--Module:Skills/Artisan for Smithing, Cooking, Herblore, etc.
--Also be aware of:
--Module:Navboxes for navigation boxes appearing near the bottom of pages


local p = {}
local p = {}
Line 36: Line 39:
   end
   end
   return nil
   return nil
end
function p.getThievingNavbox()
  local returnPart = {}
  -- Create table header
  table.insert(returnPart, '{| class="wikitable" style="text-align:center; clear:both; margin:auto; margin-bottom:1em;"')
  table.insert(returnPart, '|-\r\n!' .. Icons.Icon({'Thieving', type='skill', notext=true}) .. '[[Thieving|Thieving Targets]]')
  table.insert(returnPart, '|-\r\n|')
 
  local npcData = {}
  for i, npc in ipairs(SkillData.Thieving.NPCs) do
    table.insert(npcData, {["level"] = npc.level, ["name"] = npc.name})
  end
  table.sort(npcData, function(a, b) return a.level < b.level end)
  local npcList = {}
  -- Create row for each NPC
  for i, npc in ipairs(npcData) do
    table.insert(npcList, Icons.Icon({npc.name, type='thieving'}))
  end
  table.insert(returnPart, table.concat(npcList, ' • '))
  table.insert(returnPart, '|}')
  return table.concat(returnPart, '\r\n')
end
end