The {@link JsePlatform} class is a convenience class to standardize how globals tables are initialized for the JSE platform.
It is used to allocate either a set of standard globals using {@link #standardGlobals()} or debug globals using {@link #debugGlobals()}
A simple example of initializing globals and using them from Java is:
{@code LuaValue _G = JsePlatform.standardGlobals(); _G.get("print").call(LuaValue.valueOf("hello, world"));}
Once globals are created, a simple way to load and run a script is:
{@code LoadState.load( new FileInputStream("main.lua"), "main.lua", _G ).call();}
although {@code require} could also be used:
{@code _G.get("require").call(LuaValue.valueOf("main"));}
For this to succeed, the file "main.lua" must be in the current directory or a resource. See {@link JseBaseLib} for details on finding scripts using {@link ResourceFinder}.
The standard globals will contain all standard libraries plus {@code luajava}:
- {@link JseBaseLib}
- {@link PackageLib}
- {@link TableLib}
- {@link StringLib}
- {@link CoroutineLib}
- {@link JseMathLib}
- {@link JseIoLib}
- {@link JseOsLib}
- {@link LuajavaLib}
In addition, the {@link LuaC} compiler is installed so lua files may be loaded in their source form.
The debug globals are simply the standard globals plus the {@code debug} library {@link DebugLib}.
The class ensures that initialization is done in the correct order, and that linkage is made to {@link LuaThread#setGlobals(LuaValue)}.
@see JmePlatform