Module:Appearances

local Appearances = {} --- imported libraries -- Parses invocation and template parameters, trims whitespace, and removes blanks. local getArgs = require('Dev:Arguments').getArgs -- Output build string local output = '' -- Separator used between items in the in-line list local sep = ' &bull; ' -- Headings for each parameter the user may specify local heading = { ['adventures']			= 'Adventures', ['adventure refs']		= 'Adventures', ['novels']				= 'Novels & Short Stories', ['novel refs']			= 'Novels & Short Stories', ['films']				= 'Film & Television', ['film refs']			= 'Film & Television', ['comics']				= 'Comics', ['comic refs']			= 'Comics', ['gamebooks']			= 'Gamebooks', ['gamebook refs']		= 'Gamebooks', ['video games']			= 'Video Games', ['video game refs']		= 'Video Games', ['board games']			= 'Board Games', ['board game refs']		= 'Board Games', ['card games']			= 'Card Games', ['card game refs']		= 'Card Games', ['organized play']		= 'Organized Play & Licensed Adventures', ['organized play refs']	= 'Organized Play & Licensed Adventures' }

local function small(str) return ' '..str..' ' end -- Referenced only header local refonly = ..small('Referenced only')..

local function blockIndent(str) return ' '..str..' ' end

local function h4(str) return ' '..str..' ' end

-- function Appearances.AppList(frame) -- interprets parameters local args = getArgs(frame) -- calls the internal function that does most of the work -- sends the result back to the template / article return Appearances._AppList(args) end

function Appearances._AppList(args) if args['adventures'] or args['adventure refs'] then output = output..h4(heading['adventures']) output = output..blockIndent(args['adventures'] or '') if args['adventure refs'] then output = output..blockIndent(refonly..' '..small(args['adventure refs'])) end end if args['novels'] or args['novel refs'] then output = output..h4(heading['novels']) output = output..blockIndent(args['novels'] or '') if args['novel refs'] then output = output..blockIndent(refonly..' '..small(args['novel refs'])) end end if args['films'] or args['film refs'] then output = output..h4(heading['films']) output = output..blockIndent(args['films'] or '') if args['film refs'] then output = output..blockIndent(refonly..' '..small(args['film refs'])) end end if args['comics'] or args['comic refs'] then output = output..h4(heading['comics']) output = output..blockIndent(args['comics'] or '') if args['comic refs'] then output = output..blockIndent(refonly..' '..small(args['comic refs'])) end end if args['gamebooks'] or args['gamebook refs'] then output = output..h4(heading['gamebooks']) output = output..blockIndent(args['gamebooks'] or '') if args['gamebook refs'] then output = output..blockIndent(refonly..' '..small(args['gamebook refs'])) end end if args['video games'] or args['video game refs'] then output = output..h4(heading['video games']) output = output..blockIndent(args['video games'] or '') if args['video game refs'] then output = output..blockIndent(refonly..' '..small(args['video game refs'])) end end if args['board games'] or args['board game refs'] then output = output..h4(heading['board games']) output = output..blockIndent(args['board games'] or '') if args['board game refs'] then output = output..blockIndent(refonly..' '..small(args['board game refs'])) end end if args['card games'] or args['card game refs'] then output = output..h4(heading['card games']) output = output..blockIndent(args['card games'] or '') if args['card game refs'] then output = output..blockIndent(refonly..' '..small(args['card game refs'])) end end if args['organized play'] or args['organized play refs'] then output = output..h4(heading['organized play']) output = output..blockIndent(args['organized play'] or '') if args['organized play refs'] then output = output..blockIndent(refonly..' '..small(args['organized play refs'])) end end -- Change all semicolons to the separator character string output = string.gsub(output, ';', sep) -- Indent the whole thing output = blockIndent(output) return output end

return Appearances