No edit summary |
No edit summary |
||
Line 23: | Line 23: | ||
for _,puzzle in ipairs( data ) do |
for _,puzzle in ipairs( data ) do |
||
if type(puzzle.uk) == 'boolean' then break end |
if type(puzzle.uk) == 'boolean' then break end |
||
+ | if puzzle.episode then break end |
||
processRow( puzzle, game ) |
processRow( puzzle, game ) |
||
end |
end |
Revision as of 09:38, 27 September 2014
This Lua Module generates automatic lists of puzzles that is used in various Navbox templates. The data from which the list is generated can be edited in the PuzzleData modules. See also the Puzzle WikiProject.
-- Generates a list of puzzles for a navbox
local p = {}
local data
local ret = {}
local function processRow( puzzle, game )
if game and puzzle.game ~= game then return end
if type(puzzle.uk) == 'number' then
local ukpuzzle = data[puzzle.uk]
ret[#ret+1] = string.format("* [[Puzzle:%s|%s]]\n** [[Puzzle:%s|UK]]",puzzle.name,puzzle.number,ukpuzzle.name)
else
ret[#ret+1] = string.format("* [[Puzzle:%s|%s]]",puzzle.name,puzzle.number)
end
end
-- Build the actual thing
local function process( game )
if not data then return 'List could not be generated (check your parameters)' end
for _,puzzle in ipairs( data ) do
if type(puzzle.uk) == 'boolean' then break end
if puzzle.episode then break end
processRow( puzzle, game )
end
return table.concat( ret, '\n' )
end
function p.normal( frame )
local a = frame.args
if not a.game then return end
-- Load correct game
data = mw.loadData('Module:PuzzleData/' .. a.game)
return process()
end
function p.weekly( frame )
local a = frame.args
if not a.game then return end
-- Load weekly puzzle data
data = mw.loadData('Module:PuzzleData/weekly')
return process( a.game )
end
return p