模块:Utils:修订间差异

来自Mindustry中文wiki
无编辑摘要
无编辑摘要
第25行: 第25行:
     end
     end
     if cells == {} then return "no arg" end
     if cells == {} then return "no arg" end
     return "|-/n|"..table.concat(cell," || ")
     return "|-\n| " .. table.concat(cells, " || ")
end
end
return p
return p

2026年8月7日 (五) 18:38的版本

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

local p = {}

-- 条件函数,用法:{{#invoke:utils|ifeq|条件|为真输出|为假输出}}
function p.ifeq(frame)
    if frame.args[1] == True then
        return frame.args[2]
    else
        return frame.args[3]
    end
end
-- 一个用来打表的函数,会自动适配内容数量,用法:{{#invoke:utils|row|内容1|内容2|...}}
function p.row(frame)
    local args = frame.args
    local cell = {}

    local i = 1
    while True do
        local val = args[i]
        if val == nil then
            break
        end
        if i >20 then break end
        tabel.insert(cell,val)
        i = i + 1
    end
    if cells == {} then return "no arg" end
    return "|-\n| " .. table.concat(cells, " || ")
end
return p