6.3 – Modules

The package library provides basic facilities for loading modules in Lua. It exports one function directly in the global environment: require. Everything else is exported in a table package.

package.searchpath()
  • References/Lua/Lua/Standard Libraries/Modules

package.searchpath (name, path [, sep [, rep]]) Searches for the given name in the given path. A path is a string containing a sequence of templates

2025-01-10 15:47:30
package.cpath
  • References/Lua/Lua/Standard Libraries/Modules

package.cpath The path used by require to search for a C loader. Lua

2025-01-10 15:47:30
package.config
  • References/Lua/Lua/Standard Libraries/Modules

package.config A string describing some compile-time configurations for packages. This string is a sequence of lines: The first line is the directory separator string

2025-01-10 15:47:30
package.path
  • References/Lua/Lua/Standard Libraries/Modules

package.path The path used by require to search for a Lua loader. At

2025-01-10 15:47:30
package.loaded
  • References/Lua/Lua/Standard Libraries/Modules

package.loaded A table used by require to control which modules are already loaded

2025-01-10 15:47:30
require()
  • References/Lua/Lua/Standard Libraries/Modules

require (modname) Loads the given module. The function starts by looking into the package

2025-01-10 15:47:30
package.preload
  • References/Lua/Lua/Standard Libraries/Modules

package.preload A table to store loaders for specific modules (see require).

2025-01-10 15:47:30
package.searchers
  • References/Lua/Lua/Standard Libraries/Modules

package.searchers A table used by require to control how to load modules.

2025-01-10 15:47:30
package.loadlib()
  • References/Lua/Lua/Standard Libraries/Modules

package.loadlib (libname, funcname) Dynamically links the host program with the C library libname. If funcname is "*", then it

2025-01-10 15:47:30