Module:Adventure Squad Moves table: Difference between revisions

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search
No edit summary
No edit summary
Tag: Reverted
Line 9: Line 9:


function p.main(frame)
function p.main(frame)
local data = require("Module:Adventure Squad Move Data Cell")
local metatable = {__index = function () return "" end}
setmetatable(data, metatable)
local args = frame.args
local args = frame.args


local output = mw.html.create()
local output = mw.html.create()
local header = mw.html.create()
-- Header row
header
:tag('tr')
:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "AdventureSquad", args = {"Pokémon"}}):done()
:tag('th'):attr("colspan", "2"):attr("rowspan", "2"):cssText("width: 20%"):wikitext(frame:expandTemplate{title = "AdventureSquad", args = {"Type"}}):done()
:tag('th'):attr("rowspan", "2"):cssText("width: 20%"):wikitext(frame:expandTemplate{title = "AdventureSquad", args = {"Category"}}):done()
:tag('th'):attr("rowspan", "2"):cssText("width: 20%"):wikitext(frame:expandTemplate{title = "AdventureSquad", args = {"Level"}}):done()
:tag('th'):attr("rowspan", "2"):cssText("width: 20%"):wikitext(frame:expandTemplate{title = "AdventureSquad", args = {"PP"}}):done()
:tag('th'):attr("rowspan", "2"):cssText("width: 20%"):wikitext(frame:expandTemplate{title = "AdventureSquad", args = {"Range"}}):done()
:tag('tr')
:tag('th'):cssText("width: 20%"):wikitext("English"):done()
:tag('th'):cssText("width: 20%"):wikitext("Japanese"):done()


-- Data rows
local data = require("Module:Adventure Squad Move Data Cell")
local rows = mw.html.create()
local metatable = {__index = function () return "" end}
local i = 1
setmetatable(data, metatable)
 
while true do
local row = mw.html.create()
local monsterArg = args["pokémon_" .. i]
local levelArg = args["level_" .. i]


if not monsterArg and not levelArg then
local i = 1 -- sets the initial value to 1
break -- exit loop when no more rows are found
while true do -- starts the loop
end
local dungeonArg = args["dungeon_" .. i] -- sets the current dungeonArg to the data for dungeon_1, or dungeon_2, or dungeon_3, depending on where the loop is at
if not dungeonArg then break end -- exits the loop when there is no more data to find
-- (example: the page only has dungeon_1 and dungeon_2, so the loop ends there)
output:tag('dt'):wikitext(dungeonArg):done() -- prints the dungeonArg
output:tag('dd'):wikitext(data[dungeonArg]["version"]):done() -- takes the "version" data from the Data Cell of the current dungeonArg and prints it


local typeOne = data[monsterArg]["type1"] or ""
i = i + 1 -- increases the value by 1 to go to the next entry from the page's source (example: dungeon_1, increaases to dungeon_2, then dungeon_3, etc.)
local typeTwo = data[monsterArg]["type2"] or ""


row
:tag('tr'):done()
:tag('td'):wikitext(frame:expandTemplate{title = "AdventureSquad", args = {(monsterArg or "")}}):done()
:tag('td'):wikitext(data[monsterArg]["ja"]):done()
if typeTwo == nil or typeTwo == '' then
row
:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "AdventureSquadType", args = {typeOne}}):done()
else
row
:tag('th'):wikitext(frame:expandTemplate{title = "AdventureSquadType", args = {typeOne}}):done()
:tag('th'):wikitext(frame:expandTemplate{title = "AdventureSquadType", args = {typeTwo}}):done()
end
end


row
return tostring(output) -- prints the data
:tag('td'):wikitext((categoryArg or frame:expandTemplate{title = "Research"})):done()
 
row
:tag('td'):wikitext((levelArg or frame:expandTemplate{title = "Research"})):done()
 
row
:tag('td'):wikitext((ppArg or frame:expandTemplate{title = "Research"})):done()
 
row
:tag('td'):wikitext((rangeArg or frame:expandTemplate{title = "Research"})):done()
 
rows
:node(row)
:allDone()
 
i = i + 1
end
end
output
:tag('table'):addClass("MDWiki"):cssText("text-align: center; margin: auto; width: 50%;")
:node(header)
:node(rows)
return tostring(output)
end


return p
return p

Revision as of 21:08, 27 November 2024

Documentation for this module may be created at Module:Adventure Squad Moves table/doc

--------------------------------------------------------------------------------
--
--				Module:Adventure Squad Move Learned by Level-up table
--
--------------------------------------------------------------------------------

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

function p.main(frame)
	local args = frame.args

	local output = mw.html.create()

	local data = require("Module:Adventure Squad Move Data Cell")
	local metatable = {__index = function () return "" end}
	setmetatable(data, metatable)

	local i = 1 -- sets the initial value to 1
	while true do -- starts the loop
		local dungeonArg = args["dungeon_" .. i] -- sets the current dungeonArg to the data for dungeon_1, or dungeon_2, or dungeon_3, depending on where the loop is at
		
		if not dungeonArg then break end -- exits the loop when there is no more data to find
		-- (example: the page only has dungeon_1 and dungeon_2, so the loop ends there)
		
		output:tag('dt'):wikitext(dungeonArg):done() -- prints the dungeonArg
		output:tag('dd'):wikitext(data[dungeonArg]["version"]):done() -- takes the "version" data from the Data Cell of the current dungeonArg and prints it

		i = i + 1 -- increases the value by 1 to go to the next entry from the page's source (example: dungeon_1, increaases to dungeon_2, then dungeon_3, etc.)

		end

	return tostring(output) -- prints the data
	end

return p