lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


One last thing:

local loadLevel = function(levelpath)
   local levelenv=setmetatable({},levelMT)
   local levelcode=loadfile(levelpath)
   local MTindex={}
-- ^^ Put the definition here rather than in the main chunk

   setfenv(levelcode,levelenv)
   protectTable(_G,MTindex)
   local ret = levelcode()
   unprotectTable(_G,MTindex)
   return ret
end


-- Pierre-Yves