Class BaseLib

All Implemented Interfaces:
KryoSerializable, ResourceFinder
Direct Known Subclasses:
JseBaseLib

public abstract class BaseLib extends TwoArgFunction implements ResourceFinder, KryoSerializable
Subclass of LibFunction which implements the lua basic library functions.

This contains all library functions listed as "basic functions" in the lua documentation for JME. The functions dofile and loadfile use the Globals.finder instance to find resource files. Since JME has no file system by default, BaseLib implements ResourceFinder using Class.getResource(String), which is the closest equivalent on JME. The default loader chain in PackageLib will use these as well.

To use basic library functions that include a ResourceFinder based on

Typically, this library is included as part of a call to either

 
 Globals globals = JsePlatform.standardGlobals();
 globals.get("print").call(LuaValue.valueOf("hello, world"));
  

For special cases where the smallest possible footprint is desired, a minimal set of libraries could be loaded directly via LuaValue.load(LuaValue) using code such as:

 
 Globals globals = new Globals();
 globals.load(new JseBaseLib());
 globals.get("print").call(LuaValue.valueOf("hello, world"));
  
Doing so will ensure the library is properly initialized and loaded into the globals table.

This is a direct port of the corresponding library in C.

See Also: