I want to use LuaJava to script things like events and triggers etc.
Im confused on how integration works.
Here is what I tried:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| import org.keplerproject.luajava.LuaState; import org.keplerproject.luajava.LuaStateFactory;
public class Main { public static void main(String[] args) { LuaState l = LuaStateFactory.newLuaState(); l.openLibs(); NPCManager npcMan = new NPCManager(); l.LdoFile("hello.lua"); l.pushJavaObject(npcMan); System.out.println("Hello World from Java!"); } } |
1 2 3 4 5
| public class NPCManager { public void createNPC(String name){ System.out.println(name); } } |
1 2 3 4 5
| print("Hello world from LUA") local npcMan
npcMan:createNPC("Brad") |