Anonymous

Module:Items/ComparisonTables: Difference between revisions

From Melvor Idle
Added getItemTableRows for use with Template:ItemsTable
(Fixed a thing with the double loot table)
(Added getItemTableRows for use with Template:ItemsTable)
Line 12: Line 12:
local Items = require('Module:Items')
local Items = require('Module:Items')
local ItemSourceTables = require('Module:Items/SourceTables')
local ItemSourceTables = require('Module:Items/SourceTables')
local ItemUseTables = require('Module:Items/UseTables')


local weaponTypes = {'Magic Staff', 'Magic Wand', 'Ranged Weapon', 'Weapon'}
local weaponTypes = {'Magic Staff', 'Magic Wand', 'Ranged Weapon', 'Weapon'}
Line 304: Line 305:
   result = result..'\r\n|}'
   result = result..'\r\n|}'
   return result
   return result
end
function p.getItemTableRows(frame)
  local startID = frame.args ~= nil and frame.args[1] or frame[1]
  local rowCount = frame.args ~= nil and frame.args[2] or frame[2]
  if rowCount == nil then rowCount = 200 end
 
  local rowResult = {}
  local addedRows = 0
  for i, item in Shared.skpairs(ItemData.Items) do
    if i > startID then
      local rowTxt = '|-\r\n|'..Icons.Icon({item.name, type='item', size='50', notext=true})..'||[['..item.name..']]'
      rowTxt = rowTxt..'||'..(i - 1)..'||'..item.category..'||'..item.type..'||'..Icons.GP(item.sellsFor)
      rowTxt = rowTxt..'||'..ItemSourceTables._getItemSources(item, false, 'false')
      rowTxt = rowTxt..'||'..ItemUseTables._getItemUses(item, false, 'false')
      table.insert(rowResult, rowTxt)
      addedRows = addedRows + 1
      if addedRows >= rowCount then
        break
      end
    end
  end
  return table.concat(rowResult, '\r\n')
end
end


return p
return p