--检测没有赋值的全局变量
local tbDefineValue = {}
setmetatable(_G, {
__newindex = function(tb, key, value)
tbDefineValue[key] = true
rawset(tb, key, value)
end,
__index = function(tb, key)
if not tbDefineValue[key] then
error(string.format("找不到全局变量:%s", key))
return nil
end
end
})