tomaka / hlua

Rust library to interface with Lua
MIT License
507 stars 48 forks source link

How to read result of function with multiple return values #192

Open purplefox opened 6 years ago

purplefox commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

Hi, any updates on this?