Search code examples
actionscript-3luaalchemyalchemyapi

return values from calling a function using lua alchemy


Im calling a function in lua from actionscript using callstack : Array = luaAlchemyInstance.doString("luafunction");

my function should return some values

function luafunction()
return true, 125
end

When i look at the callstack array returned by the function in as3, I recieve only the success/ fail part. The array length is 1, true, and contains none of my return values.

Any idea whats going wrong? Cheers


Solution

  • doString() returns array of the values, returned by a call. First item of that array is true or false, indicating call success or failure. If it is false, second item is the error message.

    Also note that doString() takes actual Lua code as an argument, so it should be

    doString("return luafunction()")
    

    See documentation and example.