Difference between revisions of "Module:MonsterBox"

From Curse of Aros
Jump to: navigation, search
m
m
 
(4 intermediate revisions by the same user not shown)
Line 30: Line 30:
 
basic_row(table, 'Level', frame.args.level)
 
basic_row(table, 'Level', frame.args.level)
 
basic_row(table, '[[HP]]', frame.args.hp)
 
basic_row(table, '[[HP]]', frame.args.hp)
basic_row(table, '[[XP]]', frame.args.xp)
+
if frame.args.xp then
 +
basic_row(table, '[[Melee]] [[XP]]', frame.args.xp)
 +
end
 +
if frame.args.mgxp then
 +
basic_row(table, '[[Magic]] [[XP]]', frame.args.mgxp)
 +
end
 +
if frame.args.rgxp then
 +
basic_row(table, '[[Ranged]] [[XP]]', frame.args.rgxp)
 +
end
 
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)')
 
basic_row(table, 'Attack speed', frame.args.speed .. ' second(s)')
Line 45: Line 53:
 
end
 
end
 
if frame.args.action then
 
if frame.args.action then
basic_row(table, 'Special Action', frame.args.found)
+
basic_row(table, 'Special Action', frame.args.action)
end  
+
end
+
if frame.args.date then
 +
basic_row(table, 'Release Date', frame.args.date)
 +
end
 +
 
 
-- Separation header
 
-- Separation header
 
table:tag('tr'):tag('td'):addClass('infobox-header'):attr('colspan', 2)
 
table:tag('tr'):tag('td'):addClass('infobox-header'):attr('colspan', 2)

Latest revision as of 10:15, 15 July 2022

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, '[[HP]]', frame.args.hp)
	if frame.args.xp then
		basic_row(table, '[[Melee]] [[XP]]', frame.args.xp)
	end
	if frame.args.mgxp then	
		basic_row(table, '[[Magic]] [[XP]]', frame.args.mgxp)
	end
	if frame.args.rgxp then
		basic_row(table, '[[Ranged]] [[XP]]', frame.args.rgxp)
	end
	basic_row(table, '[[Gold]]', frame.args.gold .. ' gold')
	basic_row(table, 'Attack speed', frame.args.speed .. ' second(s)')
	
	-- Optional values
	if frame.args.damage then
		basic_row(table, '[[Damage]]', frame.args.damage)
	end
	if frame.args.respawn then
		basic_row(table, '[[Respawn]] time', frame.args.respawn .. ' second(s)')
	end
	if frame.args.found then
		basic_row(table, 'Found', frame.args.found)
	end
	if frame.args.action then
		basic_row(table, 'Special Action', frame.args.action)
	end
	if frame.args.date then
		basic_row(table, 'Release Date', frame.args.date)
	end

	-- Separation header
	table:tag('tr'):tag('td'):addClass('infobox-header'):attr('colspan', 2)
	
    return tostring(table)
end

return export