Module:Sandbox: Difference between revisions

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search
m (Removed protection from "Module:Sandbox")
No edit summary
Line 1: Line 1:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
--
-- Module:Rescue Team HM Moves table
-- Module:Rescue Team DX Dungeon Fainted Pokémon table
--
--
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Line 9: Line 9:


function p.main(frame)
function p.main(frame)
local data = mw.loadData("Module:Sandbox/test")
local args = frame.args
local args = frame.args
local output = {}
local output = {}
-- Header row
-- Header row
table.insert(output, '<table class="templateTheme" style="text-align: center; width: 50%; margin: auto;">')
table.insert(output, '<table class="templateTheme" style="text-align: center; margin: auto; width: 50%;">')
table.insert(output, '<tr>')
table.insert(output, '<tr>')
table.insert(output, '<th colspan="2" class="templatePrimary">[[File:Rescue Team - HM.png|alt=HM]]<br>' .. frame:expandTemplate{title = "RescueTeam", args = {"HM"}} .. '</th>')
table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">Sprite</th>')
table.insert(output, '<th rowspan="2" class="templatePrimary" style="width: 10%;">' .. frame:expandTemplate{title = "RescueTeam", args = {"Type"}} .. '</th>')
table.insert(output, '<th class="templatePrimary" colspan="2">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Pokémon"}} .. '</th>')
table.insert(output, '<th rowspan="2" class="templatePrimary" style="width: 20%;">Base ' .. frame:expandTemplate{title = "RescueTeam", args = {"PP"}} .. '</th>')
table.insert(output, '<th class="templatePrimary" colspan="2" rowspan="2" style="width: 20%;">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Types"}} .. '</th>')
table.insert(output, '<th rowspan="2" class="templatePrimary" style="width: 20%;">Range</th>')
table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Level"}} .. '</th>')
table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">Floors</th>')
table.insert(output, '</tr>')
table.insert(output, '</tr>')
table.insert(output, '<tr>')
table.insert(output, '<tr>')
Line 24: Line 26:
table.insert(output, '</tr>')
table.insert(output, '</tr>')
-- Data rows
-- Data rows
for i = 1, 100 do
for i = 1, 150 do
local moveArg = args["move_" .. i]
local monsterArg = args["pokémon_" .. i]
local floorsArg = args["floors_" .. i]
local levelArg = args["level_" .. i]
local levelArg = args["level_" .. i]
if not moveArg and not levelArg then
if not monsterArg and not floorsArg and not levelArg then
break -- exit loop when no more rows are found
break -- exit loop when no more rows are found
end
end
local moveType = frame:preprocess('{{#invoke:Rescue Team Move Data Cell|rescueTeamMoveDataCell|name=' .. (moveArg or "") .. '|getVar=type}}')
local typeOne = data[monsterArg or ""][type1]
local typeTwo = data[monsterArg or ""][type2]
local rowData = {}
local rowData = {}
table.insert(rowData, '<tr class="itemsTableRow">')
table.insert(rowData, '<tr class="monstersTableRow">')
if moveArg then
table.insert(rowData, '<th class="templatePrimary">' .. frame:expandTemplate{title = "RescueTeamDXSprite", args = {(monsterArg or ""), size = "50x50px"}} .. '</th>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "RescueTeam", args = {moveArg}} .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "RescueTeamDX", args = {(monsterArg or "")}} .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team Move Data Cell|rescueTeamMoveDataCell|name=' .. moveArg .. '|getVar=ja}}') .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. data[monsterArg or ""][ja] .. '</td>')
table.insert(rowData, '<td class="templatePrimary">' .. frame:expandTemplate{title = "TypePKMN", args = {moveType}} .. '</td>')
if typeTwo == nil or typeTwo == '' then
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team Move Data Cell|rescueTeamMoveDataCell|name=' .. moveArg .. '|getVar=pp}}') .. '</td>')
table.insert(rowData, '<td class="templatePrimary" colspan="2">' .. frame:expandTemplate{title = "RescueTeamDXType", args = {typeOne}} .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team Move Data Cell|rescueTeamMoveDataCell|name=' .. moveArg .. '|getVar=range}}') .. '</td>')
else
else
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
table.insert(rowData, '<td class="templatePrimary">' .. frame:expandTemplate{title = "RescueTeamDXType", args = {typeOne}} .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
table.insert(rowData, '<td class="templatePrimary">' .. frame:expandTemplate{title = "RescueTeamDXType", args = {typeTwo}} .. '</td>')
table.insert(rowData, '<td class="templatePrimary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
end
end
table.insert(rowData, '<td class="templateSecondary">' .. (levelArg or "") .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. (floorsArg or "") .. '</td>')
table.insert(rowData, '</tr>')
table.insert(rowData, '</tr>')
table.insert(output, table.concat(rowData))
table.insert(output, table.concat(rowData))

Revision as of 08:35, 14 March 2024



--------------------------------------------------------------------------------
--
--				Module:Rescue Team DX Dungeon Fainted Pokémon table
--
--------------------------------------------------------------------------------

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

function p.main(frame)
	local data = mw.loadData("Module:Sandbox/test")
	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="width: 10%;">Sprite</th>')
	table.insert(output, '<th class="templatePrimary" colspan="2">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Pokémon"}} .. '</th>')
	table.insert(output, '<th class="templatePrimary" colspan="2" rowspan="2" style="width: 20%;">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Types"}} .. '</th>')
	table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Level"}} .. '</th>')
	table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">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, 150 do
		local monsterArg = args["pokémon_" .. i]
		local floorsArg = args["floors_" .. i]
		local levelArg = args["level_" .. i]
		if not monsterArg and not floorsArg and not levelArg then
			break -- exit loop when no more rows are found
		end
		local typeOne = data[monsterArg or ""][type1]
		local typeTwo = data[monsterArg or ""][type2]
		local rowData = {}
		table.insert(rowData, '<tr class="monstersTableRow">')
		table.insert(rowData, '<th class="templatePrimary">' .. frame:expandTemplate{title = "RescueTeamDXSprite", args = {(monsterArg or ""), size = "50x50px"}} .. '</th>')
		table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "RescueTeamDX", args = {(monsterArg or "")}} .. '</td>')
		table.insert(rowData, '<td class="templateSecondary">' .. data[monsterArg or ""][ja] .. '</td>')
		if typeTwo == nil or typeTwo == '' then
			table.insert(rowData, '<td class="templatePrimary" colspan="2">' .. frame:expandTemplate{title = "RescueTeamDXType", args = {typeOne}} .. '</td>')
		else
			table.insert(rowData, '<td class="templatePrimary">' .. frame:expandTemplate{title = "RescueTeamDXType", args = {typeOne}} .. '</td>')
			table.insert(rowData, '<td class="templatePrimary">' .. frame:expandTemplate{title = "RescueTeamDXType", args = {typeTwo}} .. '</td>')
		end
		table.insert(rowData, '<td class="templateSecondary">' .. (levelArg or "") .. '</td>')
		table.insert(rowData, '<td class="templateSecondary">' .. (floorsArg or "") .. '</td>')
		table.insert(rowData, '</tr>')
		table.insert(output, table.concat(rowData))
	end
	table.insert(output, '</table>')
	return table.concat(output)
end

return p