Module:Minimal Example: Difference between revisions
Jump to navigation
Jump to search
(Created page with "-------------------------------------------------------------------------------- -- -- Module:Adventure Squad Pokémon dungeons table -- -------------------------------------------------------------------------------- local p = {} local mw = require('mw') function p.main(frame) local args = frame.args local output = mw.html.create() local test = mw.html.create() local data = require("Module:Adventure Squad Dungeon Data Cell") local metatable = {__index = fun...") |
No edit summary |
||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
-- | -- | ||
-- Module: | -- Module:Minimal Example | ||
-- | -- | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
Line 12: | Line 12: | ||
local output = mw.html.create() | local output = mw.html.create() | ||
local data = require("Module: | local data = require("Module:Minimal Example Data Cell") | ||
local metatable = {__index = function () return "" end} | local metatable = {__index = function () return "" end} | ||
setmetatable(data, metatable) | setmetatable(data, metatable) | ||
while true do | 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 | end | ||
return tostring(output) -- prints the data | |||
end | |||
return tostring(output) | |||
end | |||
return p | return p |
Latest revision as of 01:30, 9 November 2024
Documentation for this module may be created at Module:Minimal Example/doc
--------------------------------------------------------------------------------
--
-- Module:Minimal Example
--
--------------------------------------------------------------------------------
local p = {}
local mw = require('mw')
function p.main(frame)
local args = frame.args
local output = mw.html.create()
local data = require("Module:Minimal Example 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