跳转到内容

Module:Dev

此后如竟没有炬火,我便是唯一的光。

此模块的文档可以在Module:Dev/doc创建

local p = {}

-- 这个模板包含一些开发测试用工具

function p.tableToString(tbl)
    local result = {}
    
    for k, v in pairs(tbl) do
        if type(k) == "string" then
            k = string.format('"%s"', k) 
        end
        if type(v) == "table" then
            v = tableToString(v)  -- 递归处理嵌套表
        elseif type(v) == "string" then
            v = string.format('"%s"', v) 
        end
        
        table.insert(result, k .. ": " .. tostring(v))
    end
    
    return "{ " .. table.concat(result, ", ") .. " }"
end

return p