Class JseMathLib

All Implemented Interfaces:
KryoSerializable

public final class JseMathLib extends MathLib
Subclass of LibFunction which implements the lua standard math library.

It contains all lua math functions, including those not available on the JME platform.

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

 
 Globals globals = JsePlatform.standardGlobals();
 System.out.println( globals.get("math").get("sqrt").call( LuaValue.valueOf(2) ) );
  

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.load(new PackageLib());
 globals.load(new JseMathLib());
 System.out.println( globals.get("math").get("sqrt").call( LuaValue.valueOf(2) ) );
  

However, other libraries such as CoroutineLib are not loaded in this case.

This has been implemented to match as closely as possible the behavior in the corresponding library in C.

See Also: