×
创建新页面
在此填写您的页面标题:
我们当前在Undertale社区维基上拥有145个页面。请在上方输入您的页面名称或点击以下任意标题来开始编写页面!



Undertale社区维基
欢迎来到Undertale社区维基(*`∀´*)ノ亻,如果想要参与条目创建或编辑,请先登录

可在模块:AU信息框/image/doc创建此模块的帮助文档

local p = {}

function p.getImages(frame)
    local category = "AU"

    -- 获取传入的参数
    local limit = tonumber(frame.args.limit) or 10
    -- 构建查询
    local query = {}
    table.insert(query, "[[Category:" .. category .. "]]")
    table.insert(query, "?Image")
    query.mainlabel = "title" -- 设置主标签为"title"
    query.limit = limit -- 设置结果数量限制

    local result = mw.smw.ask(query) -- 执行查询

    -- 构建结果字符串
    local output = ""
    local count = 0
    if type(result) == "table" then
        for _, row in pairs(result) do
            local image = row["Image"]
            local title = row.title
            if type(image) == "table" then
                image = image[1] -- 获取表格中的第一个值
            end
            if image and title then
                output = output .. '<div class="col-md-3 p-3 text-white" style="box-sizing: border-box;">' .. "[[" .. image .. "|150px|link=" .. title .. "]]" .. '</div>'
                count = count + 1
                if limit > 0 and count >= limit then
                    break -- 达到限制数量后停止迭代
                end
            end
        end
    end

    return output
end

return p