模块:TWRSideNavBox

来自TeamMoeg官方WIKI
Lyuuke讨论 | 贡献2022年1月2日 (日) 18:11的版本 (创建页面,内容为“local p = {} itemString = "|-\n|[[File:{{{1}}}|50px|link={{FULLPAGENAME}}#{{{2}}}]]\n" function p.assemblyFixedNavBox( frame ) local returnString = "" for…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳到导航 跳到搜索

Lua错误 在第8行:attempt to index local 'v' (a function value)


local p = {}

itemString = "|-\n|[[File:{{{1}}}|50px|link={{FULLPAGENAME}}#{{{2}}}]]\n"

function p.assemblyFixedNavBox( frame )
    local returnString = ""
    for k, v in pairs(frame) do
        splitPoint = v:find("::")
        -- Format of each element: "<File Name>::<Anchor>"
        -- with no spaces to both sides of the backslash
        if splitPoint ~= nil and splitPoint > 1 then
            name1 = v:sub(1, splitPoint - 1)
            name2 = v:sub(splitPoint + 2)
            if name1:find("%.%w+$") ~= nil then
                segment = itemString:gsub("{{{1}}}", name1)
            else
                -- If no file extension is found, assumes PNG by default
                segment = itemString:gsub("{{{1}}}", name1 .. ".png")
            end
            segment = segment:gsub("{{{2}}}", name2)
            returnString = returnString .. segment
        end
    end
    return "{|\n" .. returnString .. "|}"
end

return p