Shukaro
Shukaro

Reputation: 47

Executing lua scripts from java

How would I go about executing a lua script from some directory from java that can get and set values in the calling object?

For example:

public SomeJavaClass
{
    public int someInt;

    public SomeJavaClass(int i)
    {
        this.someInt = i;
    }

    public void runLuaScript(String script)
    {
        executeSomeLuaScriptSomehow(script);
    }

    public int getSomeInt()
    {
        return someInt;
    }

    public void setSomeInt(int i)
    {
        this.someInt = i;
    }
}

And then in SomeLuaScript.lua

if javaParent.getSomeInt() > 3 then
    javaParent.setSomeInt(1)
end

Upvotes: 2

Views: 2225

Answers (1)

Mordechai
Mordechai

Reputation: 16302

LuaJava library allows java to run Lua Scripts, and vice versa.

Upvotes: 3

Related Questions