Module:Adventure Mode
Jump to navigation
Jump to search
Want an adless experience? Log in or Create an account.
Documentation for this module may be created at Module:Adventure Mode/doc
local Args = require( 'Module:Args' ) local Tabs = require( 'Module:Tabs' ) local COLS = 'ABCDEFGHIJKLMNOP' function buildMapTable( mapName, selection ) local table = mw.html.create( 'table' ) :addClass( 'zdw-tabset' ) :attr( 'data-tab-target', mapName:gsub( '%s', '' ) ) :attr( 'data-tab-type', 'click' ) for rowNum = 1, 8 do local row = table:tag( 'tr' ) rowNum = tostring( 9 - rowNum ) -- reverse so that top row is 8, bottom row is 1 for colNum in COLS:gmatch( '.' ) do local coord = colNum .. rowNum row:tag( 'td' ) :addClass( 'zdw-tab' ) :attr( 'data-tab-selection', coord ) :wikitext( '[[File:Hyrule Warriors ' .. mapName .. ' ' .. coord .. (selection == 'Map' and '' or (' ' .. selection)) .. '.png|link=]]' ) end end return table end function buildContent( mapName ) local container = mw.html.create( 'div' ) :attr( 'id', mapName:gsub( '%s', '' ) ) local frame = mw.getCurrentFrame() for rowNum = 1, 8 do for colNum in COLS:gmatch( '.' ) do local coord = colNum .. tostring( rowNum ) local title = mapName .. '/' .. coord local pageExists, pageContent = pcall( function() frame:expandTemplate{ title = title, args = {} } end ) container:tag( 'div' ) :addClass( 'zdw-tabcontent' ) :attr( 'data-tab-content', coord ) :wikitext( pageExists and pageContent or '[[' .. title .. ']]' ) end end return container end local p = {} function p.main( frame ) local args = Args.fromFrame( frame ) local mapTabs = Tabs.Tabs.new{ width = 640 } local tabSet = mapTabs:topTabs{} local tabs = { 'Map', 'Items', 'Fairies', 'Hearts', 'Gold Skulltulas' } for _, selection in ipairs( tabs ) do tabSet:addTab{ selection = selection } mapTabs:addContent{ selection = selection, content = tostring( buildMapTable( args[1], selection ) ) } end return mapTabs:render() .. tostring( buildContent( args[1] ) ) end -- for use in the debug console: -- =p.main(p.debugframe) p.debugframe = { args = {}, getParent = function() return { args = { [1] = "Adventure Map" } } end } return p