Class PackageLib

All Implemented Interfaces:
KryoSerializable

public class PackageLib extends TwoArgFunction implements KryoSerializable
Subclass of LibFunction which implements the lua standard package and module library functions.

Lua Environment Variables

The following variables are available to lua scrips when this library has been loaded:
  • "package.loaded" Lua table of loaded modules.
  • "package.path" Search path for lua scripts.
  • "package.preload" Lua table of uninitialized preload functions.
  • "package.searchers" Lua table of functions that search for object to load.

Java Environment Variables

These Java environment variables affect the library behavior:
  • "luaj.package.path" Initial value for "package.path". Default value is "?.lua"

Loading

Typically, this library is included as part of a call to either
 
 Globals globals = JsePlatform.standardGlobals();
 System.out.println( globals.get("require").call"foo") );
  

To instantiate and use it directly, link it into your globals table via LuaValue.load(LuaValue) using code such as:

 
 Globals globals = new Globals();
 globals.load(new JseBaseLib());
 globals.load(new PackageLib());
 System.out.println( globals.get("require").call("foo") );
  

Limitations

This library has been implemented to match as closely as possible the behavior in the corresponding library in C. However, the default filesystem search semantics are different and delegated to the bas library

See Also: