Anonymous

Module:ItemsTable: Difference between revisions

From Melvor Idle
Added getMazunkiItemTable function for Mazunki
(Include commands to be executed in debug console)
(Added getMazunkiItemTable function for Mazunki)
Line 57: Line 57:
   end
   end
   return table.concat(itemList, '')
   return table.concat(itemList, '')
end
function p.getMazunkiItemTable(frame)
--Generates a plaintext table for Mazunki's use for spreadsheet generation
local result = '{|'
result = result..'\r\n!ID!!Name!!Price!!Combat Obtainable!!Monster Drop Chances'
local rows = {}
local itemList = Items.getItems(function(item) return true end)
table.sort(itemList, function(a, b) return a.id < b.id end)
local monsterSourceColumns = { 'id', 'dropWt', 'totalWt', 'minQty', 'maxQty' }
local itemID = 0
local item = Items.getItemByID(itemID)
while item ~= nil and itemID < 2000 do
local rowTxt = '|-\r\n'
rowTxt = rowTxt..'|'..item.id..'||'..item.name..'||'..item.sellsFor
local monsterData = SourceTables._getItemMonsterSources(item)
if(Shared.tableCount(monsterData) > 0) then
local monsterColData = {}
for i, colName in pairs(monsterSourceColumns) do
monsterColData[colName] = {}
end
rowTxt = rowTxt..'||true||'
for j, mData in pairs(monsterData) do
for k, colName in pairs(monsterSourceColumns) do
table.insert(monsterColData[colName], mData[colName])
end
end
local colTxtArray = {}
for j, colName in pairs(monsterSourceColumns) do
table.insert(colTxtArray, 'monster_'..colName..' = '..table.concat(monsterColData[colName], ','))
end
rowTxt = rowTxt..table.concat(colTxtArray, '<br/>')
else
rowTxt = rowTxt..'||false||'
end
table.insert(rows, rowTxt)
itemID = itemID + 1
item = Items.getItemByID(itemID)
end
result = result..'\r\n'..table.concat(rows, '\r\n')..'\r\n|}'
return result
end
end


return p
return p