Minecraft Wiki
Advertisement

Este módulo implementa {{Tabela de som}}.

Uso

Este módulo não deve ser invocado; {{Tabela de som}} deve ser chamado. Consulte a documentação do modelo para obter mais informações.

[ver | editar | histórico | purgar]A documentação acima é transcluída de Módulo:Tabela de som/doc.
local p = {}
local emptyevent = [=[''Nenhum''<ref group="som" name="emptyevent">Os eventos vazios não têm esse parâmetro definido.</ref>]=]
local nosubtitle = [=[''Nenhum''<ref group="som" name="nosubtitle">[https://bugs.mojang.com/issues/?jql=project%20%3D%20MC%20AND%20resolution%20%3D%20Unresolved%20AND%20text%20~%20%22sound%20missing%22 Relatórios no Mojira].</ref>]=]

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 = [=[[[Categoria:Páginas com ]=] .. categoryName .. [=[ ausentes]]]=]
		
		value = value .. category
	end
	
	return value
end

function p.table( f )
	local args = f
	if f == mw.getCurrentFrame() then
		args = require( 'Módulo: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
		local bedrock = false
		local dungeons = false
		if args.bedrock or args.type=='bedrock' then
			vardefine( parent, 'bedrock', 1 )
			bedrockordungeons = true
			bedrock = true
			vardefine( parent, 'bedrockordungeons', 1 )
		end
		if args.dungeons or args.type=='dungeons' then
			vardefine( parent, 'dungeons', 1 )
			bedrockordungeons = true
			dungeons = true
			vardefine( parent, 'bedrockordungeons', 1 )
		end
		result = result .. [=[<table class="wikitable">]=]
		local headerrow = mw.html.create( 'tr' )
		local headings = { 'Som' }
		
		if not bedrockordungeons then
			table.insert( headings, '[[Legendas]]' )
		end
		if not dungeons then
			local sourceheading = parent:expandTemplate{ title = 'abbr', args = { 'Fonte', 'A categoria em que este som se enquadra; qual controle deslizante de volume controla este som no menu música e sons.' } }
			table.insert( headings, sourceheading )
		end
		local descriptionheading = parent:expandTemplate{ title = 'abbr', args = { 'Descrição', 'Quando o jogo chama este evento de som.' } }
		table.insert( headings, descriptionheading )
		if not dungeons then
            table.insert( headings, '[[ID de espaço de nome]]')
        end
		if not bedrockordungeons then
			table.insert( headings, 'Chave de tradução' )
		end
		if not dungeons then
			table.insert( headings, 'Volume' )
			table.insert( headings, 'Afinação' )
		end
		if not bedrockordungeons then
			table.insert( headings, 'Distância de<br>atenuação' )
		end
		
		for i, header in ipairs( headings ) do
			headerrow
				:tag( 'th' )
				:wikitext( header ) 
		end
		
		result = result .. tostring( headerrow )
	end
	
	-- Header variables
	local nocat = var( parent, 'nocat' )
	local bedrockordungeons = var( parent, 'bedrockordungeons' )
	local bedrock = var( parent, 'bedrock' )
	local dungeons = var( parent, 'dungeons' )
	
	local cells = {}
	
	local sound = ''
	if args.sound == '-' then
		sound = [=[''Nenhum'']=]
	elseif args.sound == nil then
		sound = addCategory( nocat, '?', 'sons' )
	else
		-- O primeiro parâmetro está vazio porque não queremos um nome de som
		local sounds = { '', args.sound }
		for count = 2, 20 do
			local index = 'sound' .. count
			if args[index] then
				table.insert( sounds, args[index] )
			end
		end
		
		sound = parent:expandTemplate{ title = 'Som', args = sounds }
	end
	table.insert( cells, sound )
	
	if not bedrockordungeons then
		local subtitle = args.subtitle
		if args.subtitle == '-' then
			subtitle = parent:preprocess( nosubtitle )
		elseif args.sound == '-' then
			subtitle = parent:preprocess( emptyevent )
		elseif args.translationkey == '-' then
			local content = parent:expandTemplate{ title = 'bug', args = { args.subtitle } }
			subtitle = [=[''Nenhum'']=] .. parent:extensionTag( 'ref', content, { group = 'som', name = 'bug' .. args.subtitle } )
		elseif args.subtitle ~= nil then
			subtitle = args.subtitle
		else
			subtitle = addCategory( nocat, '?', 'legendas' )
		end
		table.insert( cells, subtitle )
	end
	
	if not dungeons then
		local source = addCategory( nocat, '?', 'fontes de som' )
		if args.source == 'Volume principal' or args.source == 'master' then
			source = 'Volume principal'
		elseif args.source == 'Música' or args.source == 'music' then
			source = 'Música'
		elseif args.source == 'Blocos musicais' or args.source == 'record' then
			source = 'Blocos musicais'
		elseif args.source == 'Tempo' or args.source == 'weather' then
			source = 'Tempo'
		elseif args.source == 'Criaturas hostis' or args.source == 'hostile' then
			source = 'Criaturas hostis'
		elseif args.source == 'Criaturas inofensivas' or args.source == 'neutral' then
			source = 'Criaturas inofensivas'
		elseif args.source == 'Jogadores' or args.source == 'player' then
			source = 'Jogadores'
		elseif args.source == 'Blocos' or args.source == 'block' then
			source = 'Blocos'
		elseif args.source == 'Ambiente' or args.source == 'ambient' then
			source = 'Ambiente'
		elseif args.source == 'Voz e diálogos' or args.source == 'voice' then
			source = 'Voz e diálogos'
		elseif args.source == 'Som' or args.source == 'sound' then
			source = 'Som'
		end
        table.insert( cells, source )
	end

	local desc = args.description or addCategory( nocat, '?', 'descrições de som' )
	table.insert( cells, desc )
	
    if not dungeons then
	    local id
	    if args.id then
	    	id = [=[<code style="white-space: nowrap">]=] .. args.id .. [=[</code>]=]
	    else
	    	id = addCategory( nocat, '?', 'IDs de som' )
	    end
	    table.insert( cells, id )
    end
	
	if not bedrockordungeons then
		local translationkey
		if args.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 = [=[''Nenhum'']=] .. parent:extensionTag( 'ref', content, { group = 'som', name = 'bug' .. args.subtitle } )
		elseif args.translationkey ~= nil then
			translationkey = [=[<code style="white-space: nowrap">]=] .. args.translationkey .. [=[</code>]=]
		else
			translationkey = addCategory( nocat, '?', 'chaves de legenda' )
		end
		table.insert( cells, translationkey )
	end
	
	if not dungeons then
		table.insert( cells, args.volume or addCategory( nocat, '?', 'volumes de som' ) )
		table.insert( cells, args.pitch or addCategory( nocat, '?', 'afinações de som' ) )
	end
	if not bedrockordungeons then
		table.insert( cells, args.distance or addCategory( nocat, '?', 'distâncias de atenuação de som' ) )
	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
		-- Reinicializa as variáveis que usamos
		vardefine(parent, 'soundstable', '')
		vardefine(parent, 'nocat', '')
		vardefine(parent, 'bedrock', '')
		vardefine(parent, 'dungeons', '')
		vardefine(parent, 'bedrockordungeons', '')
		
		-- Adiciona final de tabela
		result = result .. [=[</table>]=] .. parent:expandTemplate{ title = 'lista de notas', args = { 'som' } }
	end
	
	return tostring( result )
end
return p
Advertisement