Module:Sound table

local p = {} local emptyevent = [=[None ]=] local nosubtitle = [=[None ]=]

local function vardefine( f, name, value ) f:callParserFunction( '#vardefine', name, value ) end

local function var( f, name, defaultvalue ) local result = f:callParserFunction( '#var', name, defaultvalue ) if result == '' then return nil end return result end

local function addCategory( nocat, value, categoryName ) if not nocat then local category = [=[]=] value = value .. category end return value end

function p.table( f ) local args = f	if f == mw.getCurrentFrame then args = require( 'Module:ProcessArgs' ).norm else f = mw.getCurrentFrame end local parent = f:getParent or f	local result = '' if not var( parent, 'soundstable' ) then vardefine( parent, 'soundstable', 1 ) if args.nocat then vardefine( parent, 'nocat', 1 ) end local bedrockordungeons = false if args.bedrock or args.dungeons then bedrockordungeons = true vardefine( parent, 'bedrockordungeons', 1 ) end if args.bedrock then vardefine( parent, 'bedrock', 1 ) end if args.dungeons then vardefine( parent, 'dungeons', 1 ) end result = result .. [=[ ]=]	   else id = addCategory( nocat, '?', 'sound ID' ) end table.insert( cells, id ) end if not bedrockordungeons then local translationkey if sound == '-' then translationkey = parent:preprocess( emptyevent ) elseif args.subtitle == '-' then translationkey = parent:preprocess( nosubtitle ) elseif args.translationkey == '-' then local content = parent:expandTemplate{ title = 'bug', args = { args.subtitle } } translationkey = [=[None]=] .. parent:extensionTag( 'ref', content, { group = 'sound', name = 'bug' .. args.subtitle } ) elseif args.translationkey ~= nil then translationkey = [=[ ]=] else translationkey = addCategory( nocat, '?', 'subtitle key' ) end table.insert( cells, translationkey ) end if not dungeons then table.insert( cells, args.volume or addCategory( nocat, '?', 'sound volume' ) ) table.insert( cells, args.pitch or addCategory( nocat, '?', 'sound pitch' ) ) end if not bedrockordungeons then table.insert( cells, args.distance or addCategory( nocat, '?', 'sound attenuation distance' ) ) end local row = mw.html.create( 'tr' ) for i, cell in ipairs( cells ) do		row :tag( 'td' ) :wikitext( cell ) end result = result .. tostring( row ) if args.foot then -- Reset the variables we used vardefine(parent, 'soundstable', '') vardefine(parent, 'nocat', '') vardefine(parent, 'bedrock', '') vardefine(parent, 'dungeons', '') vardefine(parent, 'bedrockordungeons', '') -- Add table ending result = result .. [=[ ]=] .. parent:expandTemplate{ title = 'notelist', args = { 'sound' } } end return tostring( result ) end return p