Module:Mob spawn biomes

local p = {} local cargo = mw.ext.cargo

-- query for a specific mob local function queryMob(mob) local tables = 'MobSpawning' local fields = 'Biome, Chance, Size' local cargoArgs = { where = 'Mob="' .. mob .. '"' }	local cargoData = cargo.query(tables, fields, cargoArgs) mw.logObject(cargoData) return cargoData end

local function createOutput(args, cargoData) local outputTable = {} local columns = {'Biome', 'Spawn chance', 'Group size'} local title = args.title table.insert(outputTable, '{| class = "wikitable"') if title then table.insert(outputTable, '! colspan = ' .. #columns .. ' | ' .. title) end local columnsStr = '! '	for index, value in pairs(columns) do		if index ~= 1 then columnsStr = columnsStr .. ' !! '		end columnsStr = columnsStr .. value end table.insert(outputTable, columnsStr) for _, biomeTable in ipairs(cargoData) do		local rowTable = {} table.insert(rowTable, '| ' .. biomeTable['Biome']) table.insert(rowTable, '| ' .. biomeTable['Chance']) table.insert(rowTable, '| ' .. biomeTable['Size']) table.insert(outputTable, table.concat(rowTable, '\n')) end table.insert(outputTable, '|}') local outputWikitext = table.concat(outputTable, '\n|-\n') return outputWikitext end

function p.getSpawnInfo(frame) local args = frame:getParent.args -- TODO use ProcessArgs local mob = args[1] local cargoData = queryMob(mob) return createOutput(args, cargoData) end

return p