Difference between revisions of "Module:MonsterBox"

From Curse of Aros
Jump to: navigation, search
Line 31: Line 31:
 
basic_row(table, 'XP', frame.args.xp)
 
basic_row(table, 'XP', frame.args.xp)
 
basic_row(table, 'Gold', frame.args.gold .. ' gold')
 
basic_row(table, 'Gold', frame.args.gold .. ' gold')
 +
basic_row(table, 'Attack speed', frame.args.speed .. ' second(s)')
 
 
 
     return tostring(table)
 
     return tostring(table)

Revision as of 11:41, 11 February 2019

Documentation for this module may be created at Module:MonsterBox/doc

local export = {}

local pagename = mw.title.getCurrentTitle().fullText

function basic_row(table, key, value)
	local row = table:tag('tr')
	
	row:tag('td'):wikitext('<b>' .. key .. '</b>')
	row:tag('td'):wikitext(value)
	
	return row
end

function export.show(frame)
	local table = mw.html.create('table'):addClass('coa-infobox'):addClass('monster')
	
	-- Create title header
	local td = table:tag('tr'):tag('td')
	td:addClass('infobox-header'):attr('colspan', '2')
		:wikitext(frame.args.name)
		
	-- Add image box
	table:tag('tr'):tag('td'):addClass('infobox-image'):attr('colspan', 2)
		:wikitext('[[File:' .. frame.args.image .. ']]')
		
	-- Separation header
	table:tag('tr'):tag('td'):addClass('infobox-header'):attr('colspan', 2)
	
	-- Monster basic attributes
	basic_row(table, 'Level', frame.args.level)
	basic_row(table, 'XP', frame.args.xp)
	basic_row(table, 'Gold', frame.args.gold .. ' gold')
	basic_row(table, 'Attack speed', frame.args.speed .. ' second(s)')
	
    return tostring(table)
end

return export