2009-10-27 06:12:24 +00:00
|
|
|
|
2012-09-21 05:24:58 +00:00
|
|
|
import org.luaj.vm2.Globals;
|
2010-05-14 04:00:05 +00:00
|
|
|
import org.luaj.vm2.LuaValue;
|
2010-07-30 18:09:31 +00:00
|
|
|
import org.luaj.vm2.lib.jse.JsePlatform;
|
2009-10-27 06:12:24 +00:00
|
|
|
|
2013-11-22 17:13:55 +00:00
|
|
|
/** Simple program showing the minimal Java program to launch a script.
|
|
|
|
|
*
|
|
|
|
|
* <p> In typical usage, a Globals object must be created to hold global state,
|
|
|
|
|
* and it can be used to compile and load lua files into executable LuaValue
|
|
|
|
|
* instances.
|
|
|
|
|
*
|
|
|
|
|
* @see Globals
|
|
|
|
|
* @see LuaValue
|
|
|
|
|
*/
|
2009-10-27 06:12:24 +00:00
|
|
|
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();
|
|
|
|
|
|
2013-11-22 17:13:55 +00:00
|
|
|
// Use the convenience function on Globals to load a chunk.
|
2013-09-18 05:32:30 +00:00
|
|
|
LuaValue chunk = globals.loadfile(script);
|
2012-10-03 14:21:26 +00:00
|
|
|
|
|
|
|
|
// Use any of the "call()" or "invoke()" functions directly on the chunk.
|
|
|
|
|
chunk.call( LuaValue.valueOf(script) );
|
2009-10-27 06:12:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|