Module:Mazunki/Monsters
From Melvor Idle
Documentation for this module may be created at Module:Mazunki/Monsters/doc
local Shared = require('Module:Shared')
local ItemData = mw.loadData('Module:Items/data')
local Items = require('Module:Items')
local Icons = require('Module:Icons')
local SourceTables = require('Module:Items/SourceTables')
local UseTables = require('Module:Items/UseTables')
local p = {}
function p.getRawTable(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
return p