I'm writing a 2D game in Java and have reached the point where I believe I'm much better off keeping the logic separate from my current game in the form of scripts, as I plan to reuse this engine for another game after I'm done with this current game. I've found the syntax and capabilities of lua to be inviting. However, I've had a hell of a time getting this to work. I got LuaJava installed and the library works in Eclipse. But when I run my hello.lua it doesn't print to the console at all. It leaves no trace of even running the script, in fact. I'm discouraged as I'd really like to get to scripting and working on my game more, but I've just had so much trouble. If no one that sees this is familiar with luajava, luaj, kahlua, etc. please refer me to a better/EASIER scripting language to implement. I know Jython and Rhino are more popular, but both seem just as complicated to implement/use.
Test.java
import org.keplerproject.luajava.LuaState;
import org.keplerproject.luajava.LuaStateFactory;
public class Test
{
public static void main(String[] args)
{
LuaState lua = LuaStateFactory.newLuaState();
lua.openLibs();
lua.LdoFile("hello.lua");
lua.close();
}
}
hello.lua
print("Hello from lua!")