模块:系列:修订间差异

来自Cookie☆Wiki
(以“local p = {} local series_table = mw.loadData('Mdoule:系列/data') --! 生成声剧系列的列表 --! @param 1 系列名 function p.generate_list() local fra...”为内容创建页面)
 
(导入10个版本)
 
(未显示同一用户的10个中间版本)
第1行: 第1行:
local p = {}
local p = {}


local series_table = mw.loadData('Mdoule:系列/data')
local series_table = mw.loadData('Module:系列/data')


--! 生成声剧系列的列表
--! 生成声剧系列的列表
第16行: 第16行:
end
end


wikitext = ''
local wikitext = ''
local name_of_this_voice_drama = frame.args[2]
for voice_drama in series do
local item_count = 0
if type(voice_drama) == 'table' then
for _, voice_drama in ipairs(series) do
wikitext = wikitext + '* [[' + voice_drama['name'] + ']] ー ' + voice_drama['note'] + '\n'
if type(voice_drama) == 'string' then
voice_drama = { name = voice_drama }
else
else
end
wikitext = wikitext + '* [[' + voice_drama + ']]\n'

local hide_for = voice_drama['hide_for']
if hide_for ~= nil then
if type(hide_for) == 'string' then
hide_for = { hide_for }
end

for _, vd_h in ipairs(hide_for) do
if name_of_this_voice_drama == vd_h then
hide_for = true
break
end
end
if hide_for ~= true then
hide_for = false
end

end
if not hide_for then
local name = voice_drama['name']
if name_of_this_voice_drama ~= name then
item_count = item_count + 1
end

wikitext = wikitext .. '* [[' .. name .. ']]'
local note = voice_drama['note']
if note ~= nil then
wikitext = wikitext .. ' ー ' .. note
end
wikitext = wikitext .. '\n'
end
end
end
end


if item_count == 0 then return '' end
return wikitext
return wikitext
end
end

2022年9月21日 (三) 23:44的最新版本

可在模块:系列/doc创建此模块的帮助文档

local p = {}

local series_table = mw.loadData('Module:系列/data')

--! 生成声剧系列的列表
--! @param 1 系列名
function p.generate_list()
    local frame = mw.getCurrentFrame()
    local series_name = frame.args[1]
    if series_name == nil then
        return ''
    end
    series = series_table[series_name]
    if series == nil then
        return ''
    end

    local wikitext = ''
    local name_of_this_voice_drama = frame.args[2]
    local item_count = 0
    for _, voice_drama in ipairs(series) do
        if type(voice_drama) == 'string' then
            voice_drama = { name = voice_drama }
        else
        end

        local hide_for = voice_drama['hide_for']
        if hide_for ~= nil then
            if type(hide_for) == 'string' then
                hide_for = { hide_for }
            end

            for _, vd_h in ipairs(hide_for) do
                if name_of_this_voice_drama == vd_h then
                    hide_for = true
                    break
                end
            end
            if hide_for ~= true then
                hide_for = false
            end

        end
        if not hide_for then
            local name = voice_drama['name']
            if name_of_this_voice_drama ~= name then
                item_count = item_count + 1
            end

             wikitext = wikitext .. '* [[' .. name .. ']]'
             local note = voice_drama['note']
             if note ~= nil then
                wikitext = wikitext .. ' ー ' .. note
             end
             wikitext = wikitext .. '\n'
        end
    end

    if item_count == 0 then return '' end
    return wikitext
end

return p