七日内新公告:全站维护公告
  • 你好~!欢迎来到萌娘百科镜像站!如需查看或编辑,请联系本站管理员注册账号。
  • 本镜像站和其他萌娘百科的镜像站无关,请注意分别。

Module:Moelib

猛汉♂百科,万男皆可猛的百科全书!转载请标注来源页面的网页链接,并声明引自猛汉百科。内容不可商用。
跳到导航 跳到搜索
Template-info.svg 模块文档  [创建] [刷新]
_G.moe = {} -- 定义为全局变量

_G.toboolean = function(value)
    if value == nil then return false
    elseif value == 0 then return false
    elseif value == "false" then return false
    else return true
    end
end

function _G.moe.import(p)
    if type(p) ~= "string" then
        p = mw.text.trim(p, "[%s%./\\]")
        if p ~= "" then
            local path = mw.text.split(p, "[%./\\]")
            if path[1] == "moe" then
                path[1] = "moelib"
            else
                table.insert(path, "moelib")
            end
            
            if #path >= 2 then
                local title = mw.title.new("模块", table.concat(path, "/"))
                if title.exists then
                    _G.moe[path[2]].require(tostring(title))
                end
            end
        end
    end
end