Module:Infobox pet

-- -- -- Module for Template:Infobox pet

local p = {}

-- "imports" local onmain = require('Module:Mainonly').on_main local infobox = require('Module:Infobox')

-- Main function called with invokes function p.main(frame) local args = frame:getParent.args local ret = infobox.new(args)

ret:defineParams{ { name = 'name', func = 'has_content' }, { name = 'image', func = 'image' }, { name = 'inventory', func = 'image' }, { name = 'itemname', func = 'has_content' }, { name = 'release', func = 'release' }, { name = 'race', func = 'has_content' }, { name = 'location', func = 'has_content' }, { name = 'skillrequired', func = 'has_content' }, { name = 'questrequired', func = 'has_content' }, { name = 'food', func = 'has_content' }, { name = 'colours', func = 'has_content' }, { name = 'examine', func = 'has_content' }, { name = 'itemexamine', func = 'has_content' }, { name = 'npcexamine', func = 'has_content' },

-- not used; only for categories { name = 'itemid', func = 'has_content' }, { name = 'npcid', func = 'has_content' }, }

ret:defineLinks( { links={{ 'Template:%s/FAQ', 'FAQ' },			{ 'Template:%s/doc', 'doc' }} })

ret:create ret:cleanParams

ret:defineName('Infobox pet') ret:addClass('infobox-pet-module')

ret:addRow{ { tag = 'argh', content = 'name', class='infobox-header', colspan = '20' } }







{ tag = 'argd', content = 'itemname', colspan = '14' } }

{ tag = 'argd', content = 'release', colspan = '14' } }

{ tag = 'argd', content = 'race', colspan = '14' } }

{ tag = 'argd', content = 'location', colspan = '14' } }

{ tag = 'argd', content = 'skillrequired', colspan = '14' } }

{ tag = 'argd', content = 'questrequired', colspan = '14' } }

{ tag = 'argd', content = 'food', colspan = '14' } }

{ tag = 'argd', content = 'colours', colspan = '14' } }



if ret:paramDefined('examine') then ret:addRow{ { tag = 'argd', content = 'examine', colspan = '20', class = 'infobox-full-width-content' } } else ret:addRow{ { tag = 'th', content = 'Inventory', colspan = '6' }, { tag = 'argd', content = 'itemexamine', colspan = '14' } } ret:addRow{ { tag = 'th', content = 'Follower', colspan = '6' }, { tag = 'argd', content = 'npcexamine', colspan = '14' } } end

if onmain then local a1 = ret:param('all') local a2 = ret:categoryData ret:wikitext(addcategories(a1, a2)) end return ret:tostring end

function addcategories(args, catargs) local ret = { 'Pets' }

-- Add the associated category if the parameter doesn't have content local notdefined_args = { image = 'Needs image', inventory = 'Needs image', release = 'Needs release date', -- examine = 'Needs examine added', -- itemexamine = 'Needs examine added', -- npcexamine = 'Needs examine added', itemid = 'Needs ID', npcid = 'Needs ID', }	for n, v in pairs(notdefined_args) do		if catargs[n] and catargs[n].all_defined == false then table.insert(ret, v)		end end

-- combine table and format category wikicode for i, v in ipairs(ret) do		if (v ~= '') then ret[i] = string.format('', v)		end end

return table.concat(ret, '') end

return p