Menu

return a java object to lua and call method from lua

lec
2014-02-21
2014-02-22
  • lec

    lec - 2014-02-21

    I like to do something like that:

    function calledFromJava(factory)
    -- works:
    local testObject = factory:createObject()
    -- does not work:
    testObject:test();
    end

    calling the lua method calledFromJava from java and calling factory:createObject() in lua work fine but I can't call any method of the returned testObject.

    My java createObject method looks like that:

    public LuaValue createObject() {
    LuaValue componentLua = CoerceJavaToLua.coerce(new TestObject());
    return componentLua;
    }

    What is the difference between passing a java object as an argument and returning an object to lua?

    Is it correct that the metadata field of componentLua:
    LuaValue componentLua = CoerceJavaToLua.coerce(new TestObject());
    if null?

    thanks!

     
  • lec

    lec - 2014-02-22

    Solved: from a private discussion with Jim: use the latest version 3.0 beta2 and return the java object directly:

    public TestObject createObject() {
    return new TestObject();
    }

     

Log in to post a comment.