将Lua5.1的setfenv迁移到Lua5.2的_ENV 文章作者 创建者:shaojingliu 文章日期 2020年4月18日 类别 属于 未分类 原来在Lua5.1中 管理器定义 function _G.Meta(name) setfenv(2, setmetatable({}, Base)) end 使用中定义 Meta(“name1”) function Execute() end 现在在Lua5.2中 管理器定义 function _G.Meta(name) return setmetatable({}, Base) end 使用中定义 local _ENV=Meta(“name1”) function Execute() end