satoren/kaguya

How to return UserdataMetatable ?

zrmei opened this issue · 1 comments

zrmei commented

I have a c++ class like

struct Data
{
    float first;
    float second;
}

I use setClass to setup UserdataMetatable

state["Data"].setClass(kaguya::UserdataMetatable<Data>()
                                      .setConstructors<Data()>()
                                      .addProperty("first" , &Data::first)
                                      .addProperty("second" , &Data::second)
                                      );

In lua file

function dosomthings(data)
    data.first = data.first * 10
    data.second = data.second * 100
    return data
end

How to return data to c++

Sorry for my poor English.

My English poor too.
I'm sorry. I don't know what you want. You want to call Lua function from c++?