Module:Sandbox: Difference between revisions

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search
No edit summary
No edit summary
Line 14: Line 14:
function p.main(frame)
function p.main(frame)
local args = frame.args
local args = frame.args
local output = "<table class=\"templateTheme\" style=\"text-align: center; margin: auto; width: 50%;\">\n"
local output = {}
-- Header row
-- Header row
output = output .. "<tr>\n"
table.insert(output, '<table class="templateTheme" style="text-align: center; margin: auto; width: 50%;">')
output = output .. "<th class=\"templatePrimary\" rowspan=\"2\" style=\"border-radius: 1rem 0 0 0; width: 10%;\">Model</th>\n"
table.insert(output, '<tr>')
output = output .. "<th class=\"templatePrimary\" colspan=\"2\">" .. frame:expandTemplate{title = "Etrian1", args = {"Monsters"}} .. "</th>\n"
table.insert(output, '<th class="templatePrimary" rowspan="2" style="border-radius: 1rem 0 0 0; width: 10%;">Model</th>')
output = output .. "<th class=\"templatePrimary\" rowspan=\"2\" style=\"width: 20%;\">" .. frame:expandTemplate{title = "Etrian1", args = {"Experience"}} .. "</th>\n"
table.insert(output, '<th class="templatePrimary" colspan="2">' .. frame:expandTemplate{title = "Etrian1", args = {"Monsters"}} .. '</th>')
output = output .. "<th class=\"templatePrimary\" rowspan=\"2\" style=\"border-radius: 0 1rem 0 0; width: 20%;\">Floors</th>\n"
table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 20%;">' .. frame:expandTemplate{title = "Etrian1", args = {"Experience"}} .. '</th>')
output = output .. "</tr>\n"
table.insert(output, '<th class="templatePrimary" rowspan="2" style="border-radius: 0 1rem 0 0; width: 20%;">Floors</th>')
output = output .. "<tr>\n"
table.insert(output, '</tr>')
output = output .. "<th class=\"templatePrimary\" style=\"width: 25%;\">English</th>\n"
table.insert(output, '<tr>')
output = output .. "<th class=\"templatePrimary\" style=\"width: 25%;\">Japanese</th>\n"
table.insert(output, '<th class="templatePrimary" style="width: 25%;">English</th>')
output = output .. "</tr>\n"
table.insert(output, '<th class="templatePrimary" style="width: 25%;">Japanese</th>')
table.insert(output, '</tr>')
-- Data rows
-- Data rows
for i = 1, 100 do
for i = 1, 100 do
Line 33: Line 36:
break -- exit loop when no more rows are found
break -- exit loop when no more rows are found
end
end
output = output .. "<tr class=\"monstersTableRow\">\n"
local rowData = {}
output = output .. "<th class=\"templatePrimary\">" .. frame:expandTemplate{title = "Etrian1Model", args = {(monsterArg or "")}} .. "</th>\n"
table.insert(rowData, '<tr class="monstersTableRow">')
output = output .. "<td class=\"templateSecondary\">" .. frame:expandTemplate{title = "Etrian1", args = {(monsterArg or "")}} .. "</td>\n"
table.insert(rowData, '<th class="templatePrimary">' .. frame:expandTemplate{title = "Etrian1Model", args = {(monsterArg or "")}} .. '</th>')
output = output .. "<td class=\"templateSecondary\">" .. frame:preprocess('{{#invoke:Etrian 1 Monster Data Cell|etrian1MonsterDataCell|name=' .. (monsterArg or "") .. '|getVar=ja}}') .. "</td>\n"
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Etrian1", args = {(monsterArg or "")}} .. '</td>')
output = output .. "<td class=\"templateSecondary\">" .. frame:preprocess('{{#invoke:Etrian 1 Monster Data Cell|etrian1MonsterDataCell|name=' .. (monsterArg or "") .. '|getVar=exp}}') .. "</td>\n"
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Etrian 1 Monster Data Cell|etrian1MonsterDataCell|name=' .. (monsterArg or "") .. '|getVar=ja}}') .. '</td>')
output = output .. "<td class=\"templateSecondary\">" .. (floorArg or "") .. "</td>\n"
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Etrian 1 Monster Data Cell|etrian1MonsterDataCell|name=' .. (monsterArg or "") .. '|getVar=exp}}') .. '</td>')
output = output .. "</tr>\n"
table.insert(rowData, '<td class="templateSecondary">' .. (floorArg or "") .. '</td>')
table.insert(rowData, '</tr>')
table.insert(output, table.concat(rowData))
end
end
output = output .. "</table>"
return output
table.insert(output, '</table>')
return table.concat(output)
end
end


return p
return p

Revision as of 09:48, 26 March 2023



----------------------------------------------------------------------------------------------------
--
--										Module:Sandbox
--
-- Here you can set anything you want in this sandbox, as long as it uses the language Lua.
-- Do not forget to add {{#invoke:Sandbox|<function name>}} in your template.
-- [[Category:Sandbox]]
--
----------------------------------------------------------------------------------------------------

local p = {}
local mw = require('mw')

function p.main(frame)
	local args = frame.args
	local output = {}
	
	-- Header row
	table.insert(output, '<table class="templateTheme" style="text-align: center; margin: auto; width: 50%;">')
	table.insert(output, '<tr>')
	table.insert(output, '<th class="templatePrimary" rowspan="2" style="border-radius: 1rem 0 0 0; width: 10%;">Model</th>')
	table.insert(output, '<th class="templatePrimary" colspan="2">' .. frame:expandTemplate{title = "Etrian1", args = {"Monsters"}} .. '</th>')
	table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 20%;">' .. frame:expandTemplate{title = "Etrian1", args = {"Experience"}} .. '</th>')
	table.insert(output, '<th class="templatePrimary" rowspan="2" style="border-radius: 0 1rem 0 0; width: 20%;">Floors</th>')
	table.insert(output, '</tr>')
	table.insert(output, '<tr>')
	table.insert(output, '<th class="templatePrimary" style="width: 25%;">English</th>')
	table.insert(output, '<th class="templatePrimary" style="width: 25%;">Japanese</th>')
	table.insert(output, '</tr>')
	
	-- Data rows
	for i = 1, 100 do
		local monsterArg = args["monster_" .. i]
		local floorArg = args["floor_" .. i]
		if not monsterArg and not floorArg then
			break -- exit loop when no more rows are found
		end
		local rowData = {}
		table.insert(rowData, '<tr class="monstersTableRow">')
		table.insert(rowData, '<th class="templatePrimary">' .. frame:expandTemplate{title = "Etrian1Model", args = {(monsterArg or "")}} .. '</th>')
		table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Etrian1", args = {(monsterArg or "")}} .. '</td>')
		table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Etrian 1 Monster Data Cell|etrian1MonsterDataCell|name=' .. (monsterArg or "") .. '|getVar=ja}}') .. '</td>')
		table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Etrian 1 Monster Data Cell|etrian1MonsterDataCell|name=' .. (monsterArg or "") .. '|getVar=exp}}') .. '</td>')
		table.insert(rowData, '<td class="templateSecondary">' .. (floorArg or "") .. '</td>')
		table.insert(rowData, '</tr>')
		table.insert(output, table.concat(rowData))
	end
	
	table.insert(output, '</table>')
	return table.concat(output)
end

return p