2

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
2
  • runLuaScript() Will recurse infinitely. .. Commented Jun 27, 2013 at 2:49
  • Just an example, clarified it a bit to show it's some other function Commented Jun 27, 2013 at 2:52

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

1 Comment

Hmm, that seems like it could do everything I need. I'll check it out

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.