今天是2025年12月20日 第51周 星期六
代人,时大变了。
我们生活在大地上,但我们的梦想超越天空。
“模块:Var”的版本间的差异
跳到导航
跳到搜索
zhmoe>屠麟傲血 小 (已保护“Module:Var”:高流量页面([编辑=仅允许管理员](无限期)[移动=仅允许管理员](无限期))) |
DrTompkins(讨论 | 贡献) 小 (导入1个版本) |
(没有差异)
| |
2023年4月12日 (三) 12:17的最新版本
local frame = mw.getCurrentFrame()
local module = {
getPlain = function(key, type)
if type then
type = '_'..type
else
type = ''
end
return frame:callParserFunction("#var"..type, tostring(key))
end,
set = function(key, val)
frame:callParserFunction("#vardefine", tostring(key), tostring(val))
return val
end
}
module.get = function(key, type)
local val = module.getPlain(key, type)
if val == '' then return nil end
if val:find('^0') then return val end
if tonumber(val) then return tonumber(val) end
if var == 'true' then return true end
if var == 'false' then return false end
return val
end
module.remove = function(key)
local removedVal = module.getPlain(key)
module.set(key, "")
return removedVal
end
return module