4
votes

I am working on a codebase in lua where all files start by module(..., package.seeall). However, this module keyword is no longer supported in Lua 5.2. The codebase is quite large and interleaving so it's kind of impossible to do require(filename) on specific files. I've read related post from Lua websites but I am still not sure What is the best/cleanest/easiest way to replace package.seeall and still be able to maintain the same functionality of requiring necessary files when running the program. thanks

1
Replace module("modulename", package.seeall) with modulename=setmetatable({_NAME="modulename"},{__index=_G}); local _ENV=modulename; _M,_PACKAGE=_ENV,_NAME:match"^.+%."or""Egor Skriptunoff

1 Answers

3
votes

module() is deprecated in Lua 5.2; you should use the new syntax (create a table inside of your program and return it). The format that was originally use is no longer supported.

If you really wish to use it, you should compile Lua with the -DLUA_COMPAT_MODULE flag.