语音:修订间差异
来自卡厄思梦境WIKI
小无编辑摘要 |
小无编辑摘要 |
||
| 第42行: | 第42行: | ||
row:tag('td'):wikitext(voice.type) | row:tag('td'):wikitext(voice.type) | ||
-- 韩语播放按钮 | -- 韩语播放按钮 | ||
local krPath = baseUrl .. "/kr/" .. characterId .. "/" .. voice.file | local krPath = baseUrl .. "/kr/" .. characterId .. "/" .. voice.file | ||
local krButton = mw.html.create('div') | local krButton = mw.html.create('div') | ||
:addClass('voice-play-button') | :addClass('voice-play-button') | ||
:attr('data-voice-url', krPath) | :attr('data-voice-url', krPath) | ||
:wikitext(' | :wikitext('▶') | ||
row:tag('td') | row:tag('td') | ||
| 第53行: | 第53行: | ||
:node(krButton) | :node(krButton) | ||
-- 日语播放按钮 | -- 日语播放按钮 | ||
local jpPath = baseUrl .. "/jp/" .. characterId .. "/" .. voice.file | local jpPath = baseUrl .. "/jp/" .. characterId .. "/" .. voice.file | ||
local jpButton = mw.html.create('div') | local jpButton = mw.html.create('div') | ||
:addClass('voice-play-button') | :addClass('voice-play-button') | ||
:attr('data-voice-url', jpPath) | :attr('data-voice-url', jpPath) | ||
:wikitext(' | :wikitext('▶') | ||
row:tag('td') | row:tag('td') | ||
2025年11月8日 (六) 15:40的版本
此模块的文档可以在模块:语音/doc创建
local p = {}
function p.main(frame)
local characterName = frame.args[1] or frame:getParent().args[1]
if not characterName or characterName == "" then
return "错误:请提供战斗员名称"
end
-- 尝试加载语音数据模块
local success, voiceData = pcall(require, "模块:语音/" .. characterName)
if not success then
return "错误:未找到战斗员 " .. characterName .. " 的语音数据"
end
-- 从文件名中提取角色ID
local characterId = ""
if voiceData[1] and voiceData[1].file then
characterId = voiceData[1].file:match("vo_(%d+)_")
end
-- 语音文件基础 URL
local baseUrl = "https://cznwiki.com/voice"
-- 创建表格
local html = mw.html.create('table')
:addClass('wikitable voice-table')
-- 表头
local headerRow = html:tag('tr')
headerRow:tag('th'):wikitext('类型'):css('width', '15%')
headerRow:tag('th'):wikitext('韩语'):css('width', '5%'):css('text-align', 'center')
headerRow:tag('th'):wikitext('日语'):css('width', '5%'):css('text-align', 'center')
headerRow:tag('th'):wikitext('文本'):css('width', '75%')
-- 数据行
for _, voice in ipairs(voiceData) do
local row = html:tag('tr')
-- 类型
row:tag('td'):wikitext(voice.type)
-- 韩语播放按钮
local krPath = baseUrl .. "/kr/" .. characterId .. "/" .. voice.file
local krButton = mw.html.create('div')
:addClass('voice-play-button')
:attr('data-voice-url', krPath)
:wikitext('▶')
row:tag('td')
:css('text-align', 'center')
:node(krButton)
-- 日语播放按钮
local jpPath = baseUrl .. "/jp/" .. characterId .. "/" .. voice.file
local jpButton = mw.html.create('div')
:addClass('voice-play-button')
:attr('data-voice-url', jpPath)
:wikitext('▶')
row:tag('td')
:css('text-align', 'center')
:node(jpButton)
-- 文本内容
local textDiv = mw.html.create('div')
:addClass('voice-text')
:wikitext(
(voice.text_cn or "") .. "<br>" ..
(voice.text_kr or "") .. "<br>" ..
(voice.text_jp or "")
)
row:tag('td'):node(textDiv)
end
return tostring(html)
end
return p