Module:SkillUnlocks: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 9: Line 9:
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
local Items = require('Module:Items')
local Items = require('Module:Items')
local CHECK_ITEMS = {'Attack', 'Strength', 'Defence', 'Ranged', 'Magic'}


function p._getAllItemsWithSkillRequirement(skillReqLabel)
function p._getAllItemsWithSkillRequirement(skillReqLabel)
Line 34: Line 36:
local skillReqLabel = skillName:lower() .. 'LevelRequired'
local skillReqLabel = skillName:lower() .. 'LevelRequired'
local itemList = p._getAllItemsWithSkillRequirement(skillReqLabel)
-- What do we need to check for this skill? (we avoid checking everything
-- for every skill to save time)
local itemList = {}
if Shared.contains(CHECK_ITEMS, skillName) then
itemList = p._getAllItemsWithSkillRequirement(skillReqLabel)
end
if Shared.tableIsEmpty(itemList) then
if Shared.tableIsEmpty(itemList) then
-- TODO: Omit empty tables
-- TODO: Omit empty tables
Line 68: Line 76:
-- Append item to the column
-- Append item to the column
table.insert(resultPart, Icons.Icon({item.item.name, type='item'}))
local verb = ''
if item.item.type == 'Weapon' then
verb = 'Wield '
elseif item.item.type == 'Armour' then
verb = 'Wear '
end
table.insert(resultPart, verb .. Icons.Icon({item.item.name, type='item'}))
end
end
73

edits