Module:Adventure Squad Moves table: Difference between revisions

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search
No edit summary
Tag: Reverted
m (Reverted edits by B (talk) to last revision by Jubilee)
Tag: Rollback
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 rows = mw.html.create()
local i = 1


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


local i = 1 -- sets the initial value to 1
if not monsterArg and not levelArg then
while true do -- starts the loop
break -- exit loop when no more rows are found
local dungeonArg = args["move_" .. i] -- sets the current dungeonArg to the data for dungeon_1, or dungeon_2, or dungeon_3, depending on where the loop is at
end
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]["ja"]):done()
output:tag('dd'):wikitext(data[dungeonArg]["type"]):done()
output:tag('dd'):wikitext(data[dungeonArg]["pp"]):done()
output:tag('dd'):wikitext(data[dungeonArg]["range"]):done()


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 typeOne = data[monsterArg]["type1"] or ""
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


return tostring(output) -- prints the data
row
: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:18, 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 data = require("Module:Adventure Squad Move Data Cell")
	local metatable = {__index = function () return "" end}
	setmetatable(data, metatable)
	local args = frame.args

	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 rows = mw.html.create()
	local i = 1

	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
			break -- exit loop when no more rows are found
		end

		local typeOne = data[monsterArg]["type1"] or ""
		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

		row
			: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

	output
		:tag('table'):addClass("MDWiki"):cssText("text-align: center; margin: auto; width: 50%;")
			:node(header)
			:node(rows)
	return tostring(output)

end

return p