Anonymous

Module:ItemsTable: Difference between revisions

From Melvor Idle
Update for v1.1
(Update for v1.1)
(Update for v1.1)
Line 2: Line 2:
-- run p.getItemsTableAlt() in debug and copy the result to [[Template:ItemsTable]] after an update that adds new items.
-- run p.getItemsTableAlt() in debug and copy the result to [[Template:ItemsTable]] after an update that adds new items.
--[=[
--[=[
mw.log(p.getItemsTableAlt(0))
mw.log(p.getItemsTableAlt(nil, 60))
mw.log(p.getItemsTableAlt(125))
mw.log(p.getItemsTableAlt(250))
mw.log(p.getItemsTableAlt(375))
mw.log(p.getItemsTableAlt(500))
mw.log(p.getItemsTableAlt(625))
mw.log(p.getItemsTableAlt(750))
mw.log(p.getItemsTableAlt(875))
mw.log(p.getItemsTableAlt(1000))
mw.log(p.getItemsTableAlt(1125))
mw.log(p.getItemsTableAlt(1250))
--]=]
--]=]


Line 36: Line 26:


--Alternate version that has everything still
--Alternate version that has everything still
function p.getItemsTableAlt(startID)
function p.getItemsTableAlt(fromItemID, rows)
   local itemList = {}
   local itemList = {}
   local endID = startID + 125
   local rowCount = 0
  local genRows = false
   for i, item in ipairs(GameData.rawData.items) do
   for i, item in ipairs(GameData.rawData.items) do
     if i > endID then
     if not genRows then
      genRows = fromItemID == nil or item.id == fromItemID
    elseif genRows then
      rowCount = rowCount + 1
      if rowCount > rows then
         break
         break
    elseif i >= startID and i <= endID then
      end
        local iCat = item.category ~= nil and item.category or ''
      local iCat = item.category ~= nil and item.category or ''
        local itemRow = {'\r\n|-'}
      local itemRow = {'\n|-'}
        table.insert(itemRow, '\r\n|'..Icons.Icon({item.name, type='item', notext=true, size=50}))
      table.insert(itemRow, '\n|'..Icons.Icon({item.name, type='item', notext=true, size=50}))
        table.insert(itemRow, '||'..Icons.Icon({item.name, type='item', noicon=true})..'||'..(i)..'||'..iCat..'||'..item.type)
      table.insert(itemRow, '||'..Icons.Icon({item.name, type='item', noicon=true})..'||'..item.id..'||'..iCat..'||'..item.type)
        table.insert(itemRow, '|| '..Items._getItemStat(item, 'completionReq'))
      table.insert(itemRow, '|| '..Items._getItemStat(item, 'completionReq'))
        table.insert(itemRow, '||data-sort-value="'..math.floor(item.sellsFor)..'"|'..Icons.GP(math.floor(item.sellsFor)))
      table.insert(itemRow, '||data-sort-value="'..math.floor(item.sellsFor)..'"|'..Icons.GP(math.floor(item.sellsFor)))
        table.insert(itemRow, '||style="text-align:right;"|'..SourceTables._getItemSources(item))
      table.insert(itemRow, '||style="text-align:right;"|'..SourceTables._getItemSources(item))
        table.insert(itemRow, '||style="text-align:right;"|'..UseTables._getItemUses(item, false))
      table.insert(itemRow, '||style="text-align:right;"|'..UseTables._getItemUses(item, false))
        table.insert(itemList, table.concat(itemRow))
      table.insert(itemList, table.concat(itemRow))
     end
     end
   end
   end