Module:Items/ComparisonTables: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 8: Line 8:
local Items = require('Module:Items')
local Items = require('Module:Items')
local Num = require('Module:Number')
local Num = require('Module:Number')
local FL = require('Module:FunList')


local weaponTypes = {'Magic Staff', 'Magic Wand', 'Ranged Weapon', 'Weapon'}
local weaponTypes = {'Magic Staff', 'Magic Wand', 'Ranged Weapon', 'Weapon'}
Line 221: Line 222:
local iconSize = 20
local iconSize = 20


local isWeapon = (slot == 'Weapon' or slot == twoHandedWeaponID)
-- If slot is nil, find out if we have any weapons.
if slot == nil then
local fl = FL.new(itemList)
if fl:any(function(x) return Shared.contains(item.validSlots, 'Weapon') end) then
slot = 'Weapon'
end
end
local isWeapon = (slot == 'Weapon' or slot == '2hWeapons')
local itemColspan = 3
local itemColspan = 3
if isWeapon == true then itemColspan = 4 end
if isWeapon == true then itemColspan = 4 end
Line 337: Line 346:


function p.getTableForList(frame)
function p.getTableForList(frame)
local pFrame = frame:getParent()
--local pFrame = frame:getParent()
local frameArgs = pFrame.args ~= nil and pFrame.args or frame
--local frameArgs = pFrame.args ~= nil and pFrame.args or frame
local includeModifiers = frameArgs.includeModifiers ~= nil and string.upper(frameArgs.includeModifiers) == 'TRUE' or false
--local includeModifiers = frameArgs.includeModifiers ~= nil and string.upper(frameArgs.includeModifiers) == 'TRUE' or false


local itemList, errItems = {}, {}
local itemList, errItems = {}, {}
for i, rawItemName in ipairs(frameArgs) do
for i, rawItemName in ipairs({}) do
local itemName = Shared.trim(rawItemName)
local itemName = Shared.trim(rawItemName)
local item = Items.getItem(itemName)
local item = Items.getItem(itemName)
Line 351: Line 360:
end
end
end
end
 
if not Shared.tableIsEmpty(errItems) then
if not Shared.tableIsEmpty(errItems) then
return Shared.printError('Some items not found in database: ' .. table.concat(errItems, ', '))
return Shared.printError('Some items not found in database: ' .. table.concat(errItems, ', '))
2,875

edits