hlua icon indicating copy to clipboard operation
hlua copied to clipboard

How to read result of function with multiple return values

Open purplefox opened this issue 6 years ago • 2 comments

Hi,

I am executing a Lua function with LuaFunction::call_with_args. The implementation of the LuaFunction returns two boolean return values. I have assumed this will be returned to rust as a tuple (bool , bool) but this gives me LuaError(WrongType) when I execute the function.

I am executing the function like this:

func.call_with_args::<(bool, bool), _, _>((arg1, arg2))

The Lua function looks something like:

function (p1, p2)
    return true, false
end

Any ideas as to what I am doing wrong?

purplefox avatar Jun 02 '18 13:06 purplefox

I also tried with:

func.call_with_args::<(AnyLuaValue, AnyLuaValue), _, _>((arg1, arg2))

If I return true, true then I get back (LuaBoolean(true), LuaOther) If I return "str1", "str2", I get back (LuaString("str1"), LuaOther)

The second element of the tuple always seems to be LuaOther irrespective of what is returned from the function

purplefox avatar Jun 02 '18 16:06 purplefox

Hi, any updates on this?

purplefox avatar Jun 13 '18 10:06 purplefox