Files
luaj/examples/jse/SampleJseMain.java

24 lines
644 B
Java
Raw Normal View History

2012-09-21 05:24:58 +00:00
import org.luaj.vm2.Globals;
import org.luaj.vm2.LuaValue;
2010-07-30 18:09:31 +00:00
import org.luaj.vm2.lib.jse.JsePlatform;
2012-10-03 14:21:26 +00:00
/** 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
2012-10-03 14:21:26 +00:00
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) );
}
}