Improve documentation and samples.

This commit is contained in:
James Roseborough
2012-10-03 14:21:26 +00:00
parent 1f69fa38ba
commit 1a4eb0e3c7
7 changed files with 120 additions and 35 deletions

View File

@@ -1,18 +1,22 @@
import org.luaj.vm2.Globals;
import org.luaj.vm2.LuaValue;
import org.luaj.vm2.lib.jse.JsePlatform;
/** Simple program showing the minimal Java program to launch a script. */
public class SampleJseMain {
public static void main(String[] args) throws Exception {
String script = "examples/lua/hello.lua";
// create an environment to run in
Globals _G = JsePlatform.standardGlobals();
_G.loadFile(script).arg1().call( LuaValue.valueOf(script) );
Globals globals = JsePlatform.standardGlobals();
// Use the convenience function on the globals to load a chunk.
LuaValue chunk = globals.loadFile(script);
// Use any of the "call()" or "invoke()" functions directly on the chunk.
chunk.call( LuaValue.valueOf(script) );
}