モジュール:Sound table
このモジュールは {{Sound table}}
を実装しています。
使用法[ソースを編集]
このモジュールは {{Sound table}}
以外からは直接呼び出さないでください。詳細は、テンプレートの解説を参照してください。
[閲覧 | 編集 | 履歴 | キャッシュ破棄]上記の解説は、モジュール:Sound table/docから参照されています。
local p = {}
local emptyevent = [=[''なし''<ref group="sound" name="emptyevent">空のイベントにはこのパラメータは設定されていません。</ref>]=]
local nosubtitle = [=[''なし''<ref group="sound" name="nosubtitle">[https://bugs.mojang.com/browse/MC-91042?jql=text%20~%20%22sound%20missing%22%20and%20resolution%20not%20in%20(%22Fixed%22%2C%20%22Cannot%20Reproduce%22%2C%20Duplicate%2C%20Invalid)%20and%20project%20%3D%20%22Minecraft%3A%20Java%20Edition%22 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 = [=[[[カテゴリ:]=] .. categoryName .. [=[が不足しているページ]]]=]
value = value .. category
end
return value
end
function p.table( f )
local args = f
if f == mw.getCurrentFrame() then
args = require( 'モジュール: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 .. [=[<table class="wikitable">]=]
local headerrow = mw.html.create( 'tr' )
local headings = { 'サウンド' }
if not bedrockordungeons then
table.insert( headings, '[[字幕]]' )
end
if not args.dungeons then
local sourceheading = parent:expandTemplate{ title = 'abbr', args = { 'ソース', 'サウンド設定メニューのどのスライダーを操作するかを表すサウンドのカテゴリ' } }
table.insert( headings, sourceheading )
end
local descriptionheading = parent:expandTemplate{ title = 'abbr', args = { '説明', 'ゲームがこのサウンドイベント呼び出すタイミング' } }
table.insert( headings, descriptionheading )
table.insert( headings, args.dungeons and 'ファイル' or '[[名前空間ID]]')
if not bedrockordungeons then
table.insert( headings, '字幕キー' )
end
if not args.dungeons then
table.insert( headings, '音量' )
table.insert( headings, 'ピッチ' )
end
if not bedrockordungeons then
table.insert( headings, '減衰<br>距離' )
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 = '-'
elseif args.sound == nil then
sound = addCategory( nocat, '?', 'サウンド' )
else
-- First parameter is empty because we don't want a sound name
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 = 'Sound', args = sounds }
end
table.insert( cells, sound )
if not bedrockordungeons then
local subtitle = args.subtitle
if args.subtitle == '-' then
subtitle = parent:preprocess( nosubtitle )
elseif sound == '-' then
subtitle = parent:preprocess( emptyevent )
elseif args.translationkey == '-' then
local content = parent:expandTemplate{ title = 'bug', args = { args.subtitle } }
subtitle = [=[''なし'']=] .. parent:extensionTag( 'ref', content, { group = 'sound', name = 'bug' .. args.subtitle } )
elseif args.subtitle ~= nil then
subtitle = args.subtitle
else
subtitle = addCategory( nocat, '?', 'サウンドの字幕' )
end
table.insert( cells, subtitle )
end
if not dungeons then
local source = args.source or addCategory( nocat, '?', 'サウンドのソース値' )
table.insert( cells, source )
end
local desc = args.description or addCategory( nocat, '?', 'サウンドの説明' )
table.insert( cells, desc )
local id
if args.id then
id = [=[<code style="white-space: nowrap">]=] .. args.id .. [=[</code>]=]
else
id = addCategory( nocat, '?', 'サウンドのID' )
end
table.insert( cells, id )
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 = [=[<code style="white-space: nowrap">]=] .. args.translationkey .. [=[</code>]=]
else
translationkey = addCategory( nocat, '?', 'サウンドの字幕キー' )
end
table.insert( cells, translationkey )
end
if not dungeons then
table.insert( cells, args.volume or addCategory( nocat, '?', 'サウンドの音量値' ) )
table.insert( cells, args.pitch or addCategory( nocat, '?', 'サウンドのピッチ値' ) )
end
if not bedrockordungeons then
table.insert( cells, args.distance or addCategory( nocat, '?', 'サウンドの減衰距離値' ) )
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 .. [=[</table>]=] .. parent:expandTemplate{ title = 'notelist', args = { 'sound' } }
end
return tostring( result )
end
return p