Module:ItemInfo

-- local p = {} require('Module:LoadLib')(_G, {	{ 'Odds', values={ makeOdds='_odds' }},	{ 'Arguments', values={ 'getArgs' }},	{ 'Item', values={ itemDisplay='_itemDisplay' }},	{ 'RarityTier', values={ makeRarity='_link' }},	{ "Sprite", values={ mobSprite='_mobSprite', locationSprite='_locationSprite' }},	{ 'Notice', values={ infoNeeded='_info_needed' }},	{ 'Currency', values={ makeCoins='_coins' }},	{ "Color", values={ 'makeColor' }},	string='String',	table='Table',	yesno='Yesno',	format='Format', }, { doAutoLoads=false })

local statdata = mw.loadData('Module:Statname/Data')

function p.mobInfo(frame) -- p.mobInfo{ mob = 'Zombie Soldier', level = '83', spawn_location = 'The Catacombs - Floor III', hp = '140000', dmg = '1640', cxp = '52', exp = '30', c = '1' } local args = getArgs(frame) local data = { mob = args.mob or args.name or args[1], image = args.image, caption = args.caption, levels = {args.level}, spawn_locations = {args.spawn_location}, stats = {}, drops = { combat_xp = {args.combat_xp or args.cxp}, experience = {args.experience or args.exp}, coins = {args.coins or args.c}, },	}	for k, v in pairs(statdata) do		if args[v.name:lower:gsub(' ', '_')] or args[v.nameShort:lower:gsub(' ', '_')] or args[v.nameSuperShort:lower:gsub(' ', '_')] or args[v.shortcode] then data.stats[v.shortcode] = {color = v.color, aliases = {v.name:lower:gsub(' ', '_'), v.nameShort:lower:gsub(' ', '_'), v.nameSuperShort:lower:gsub(' ', '_'), v.shortcode}} data.stats[v.shortcode][1] = args[v.shortcode] end end for i = 2, table.length(args), 1 do       data.levels[i] = args['level'..i]        data.spawn_locations[i] = args['spawn_location'..i]

for k, v in pairs(data.stats) do       	for _, alias in ipairs(v.aliases) do        		if not data.stats[k][i] then data.stats[k][i] = args[alias..i]		       end end end

data.drops.combat_xp[i] = args['combat_xp'..i] or args['cxp'..i]       data.drops.experience[i] = args['experience'..i] or args['exp'..i]		data.drops.coins[i] = args['coins'..i] or args['c'..i]	end mw.logObject(data) return mw.getCurrentFrame:preprocess(p._mobInfo(data)) end

function p._mobInfo(data) local ROWS = math.max(#data.levels, #data.spawn_locations, #data.drops.combat_xp, #data.drops.experience, #data.drops.coins) mw.log('rows:', ROWS)

local wikitable = mw.html.create('table'):addClass('wikitable centertext') wikitable:tag('caption'):wikitext(data.caption):done :tag('tr') :tag('th'):attr('rowspan', '2'):wikitext('Mob'):done :tag('th'):attr('rowspan', '2'):wikitext('Level'):done :tag('th'):attr('rowspan', '2'):wikitext('Spawn Location'):done :tag('th'):attr('colspan', table.length(data.stats)):wikitext('Stats'):done :tag('th'):attr('colspan', '3'):wikitext('Drops'):done :done

local row = wikitable:tag('tr') for k, v in pairs(data.stats) do	           row:tag('th'):wikitext(''):done end row:tag('th'):wikitext(''):done :tag('th'):wikitext('Experience'):done :tag('th'):wikitext(''):done row:done

local row = wikitable:tag('tr') :tag('td'):attr('rowspan', ROWS):wikitext(' \'\'\ .. data.mob .. '\'\'\):done :tag('td'):wikitext(''):done :tag('td'):wikitext(data.spawn_locations[1]):done for k, v in pairs(data.stats) do           row:tag('td'):wikitext(makeColor(v.color, string._formatNum(v[1] or '0'))):done end row:tag('td'):wikitext(makeColor('green', data.drops.combat_xp[1] or '0')):done :tag('td'):wikitext(makeColor('blue', data.drops.experience[1] or '0')):done :tag('td'):wikitext(makeColor('gold', data.drops.coins[1] or '0')):done row:done

for i = 2, ROWS, 1 do       local row = wikitable:tag('tr') :tag('td'):wikitext(''):done :tag('td'):wikitext(data.spawn_locations[i]):done for k, v in pairs(data.stats) do	           row:tag('td'):wikitext(makeColor(v.color, string._formatNum(v[i] or '0'))):done end row:tag('td'):wikitext(makeColor('green', data.drops.combat_xp[i] or '0')):done :tag('td'):wikitext(makeColor('blue', data.drops.experience[i] or '0')):done :tag('td'):wikitext(makeColor('gold', data.drops.coins[i] or '0')):done row:done end

return tostring(wikitable) end

return p