Module:Items/ComparisonTables: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 221: Line 221:
function p.getEquipmentTable(itemList, slot)
function p.getEquipmentTable(itemList, slot)
local iconSize = 20
local iconSize = 20
 
local fl = FL.new(itemList)
-- If slot is nil, find out if we have any weapons.
-- If slot is nil, find out if we have any weapons.
if slot == nil then
if slot == nil then
local fl = FL.new(itemList)
if fl:any(function(x) return Shared.contains(x.validSlots, 'Weapon') end) then
if fl:any(function(x) return Shared.contains(x.validSlots, 'Weapon') end) then
slot = 'Weapon'
slot = 'Weapon'
Line 230: Line 230:
end
end
-- Sort itemList by name
itemList = fl:sortBy(function(x) return x.name end)
:sort()
:toTable()
local isWeapon = (slot == 'Weapon' or slot == '2hWeapons')
local isWeapon = (slot == 'Weapon' or slot == '2hWeapons')
local itemColspan = 3
local itemColspan = 3
Line 338: Line 343:
end
end


-- Always sort by name.
return p.getEquipmentTable(getItems(slotID), slot)
local itemList = getItems(slotID)
table.sort(itemList, function(a, b) return a.name < b.name end)
 
return p.getEquipmentTable(itemList, slot)
end
end


2,875

edits