local p = {}
local data = mw.loadData('Module:Sandbox/SoundEvent/ID')
function normalizeArg(arg, default)
default = default == 'NULL' and '' or default
return arg or default
end
function p.table(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
end
f = mw.getCurrentFrame()
local id = args[1]
if data[id] then
local description = normalizeArg(args.description, data[id][4])
local source = normalizeArg(args.source, data[id][5])
local foot = args.foot
local soundTableArgs = {}
for i = 1, data[id][2] do
soundTableArgs['sound' .. (i == 1 and '' or i)] = data[id][1] .. i .. '.ogg'
end
soundTableArgs['subtitle'] = f:expandTemplate {title = 'Sc', args = {data[id][3]}}
soundTableArgs['description'] = description
soundTableArgs['source'] = source
soundTableArgs['translationkey'] = data[id][3]
soundTableArgs['id'] = id
if foot then
soundTableArgs['foot'] = foot
end
return f:expandTemplate {title = 'Sound table', args = soundTableArgs}
else
return id..'[[Category:未知的音效事件ID]]'
end
end
function p.doc(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
end
f = mw.getCurrentFrame()
local num = tonumber(f.args[1])
local block = 150
local foot = '1'
local soundTableArgs = {}
local out=''
local count=1
for id in pairs(data) do
if count >= block * num then
break
end
while true do
if count < block * (num - 1) then
break
end
local description = data[id][4]
local source = data[id][5]
for i = 1, data[id][2] do
soundTableArgs['sound' .. (i == 1 and '' or i)] = data[id][1] .. (data[id][2]==1 and '' or i).. '.ogg'
end
soundTableArgs['subtitle'] = f:expandTemplate {title = 'Sc', args = {data[id][3]}}
soundTableArgs['description'] = description
soundTableArgs['source'] = source
soundTableArgs['translationkey'] = data[id][3]
soundTableArgs['id'] = id
if count == block * num - 1 then
soundTableArgs['foot'] = foot
end
out=out..f:expandTemplate {title = 'Sound table', args = soundTableArgs}
break
end
soundTableArgs = {}
count = count + 1
end
return out
end
return p
Advertisement
Advertisement