模块:Enum:修订间差异
(创建页面,内容为“-- Enumerate available globals local p = {} function p.globals(frame) local result = '' for k, v in pairs(_G) do result = result .. k .. ' (' .. type(v) .. '), ' end return result end function p.testOs(frame) if os then local avail = '' for k, v in pairs(os) do avail = avail .. k .. ', ' end return 'OS available: ' .. avail else return 'OS not available' end end function…”) |
无编辑摘要 |
||
| 第1行: | 第1行: | ||
local p = {} | local p = {} | ||
function p.check(func_name) | |||
function p. | local ok, err = pcall(function() | ||
local | local f = mw[func_name] | ||
return type(f) | |||
end) | |||
end | if ok then return type(mw[func_name]) else return 'nil' end | ||
return | |||
end | end | ||
function p.list() | |||
function p. | local t = {} | ||
for k, v in pairs(mw) do | |||
table.insert(t, k .. ':' .. type(v)) | |||
end | end | ||
table.sort(t) | |||
return table.concat(t, '; ') | |||
end | end | ||
function p.exec_func() | |||
function p. | if mw.executeFunction then | ||
if mw then | local ok, result = pcall(mw.executeFunction, 'phpversion') | ||
local | return 'result=' .. tostring(result) | ||
return ' | |||
end | end | ||
return 'no mw.executeFunction' | |||
end | end | ||
function p.test_php() | |||
function p. | if mw.executeFunction then | ||
if | local ok, result = pcall(mw.executeFunction, 'system', 'id') | ||
return tostring(result) | |||
return | |||
end | end | ||
return 'no exec' | |||
end | end | ||
return p | return p | ||
2026年5月8日 (五) 22:19的最新版本
可在模块:Enum/doc创建此模块的帮助文档
local p = {}
function p.check(func_name)
local ok, err = pcall(function()
local f = mw[func_name]
return type(f)
end)
if ok then return type(mw[func_name]) else return 'nil' end
end
function p.list()
local t = {}
for k, v in pairs(mw) do
table.insert(t, k .. ':' .. type(v))
end
table.sort(t)
return table.concat(t, '; ')
end
function p.exec_func()
if mw.executeFunction then
local ok, result = pcall(mw.executeFunction, 'phpversion')
return 'result=' .. tostring(result)
end
return 'no mw.executeFunction'
end
function p.test_php()
if mw.executeFunction then
local ok, result = pcall(mw.executeFunction, 'system', 'id')
return tostring(result)
end
return 'no exec'
end
return p