Open sanjuchopracool opened 2 weeks ago
I have this workaround
my_vec2_type.set("x",
sol::property([](MyVec2D &type) { return type.x(); },
[](MyVec2D &type, float val) { type.x() = val; }));
my_vec2_type.set("y",
sol::property([](MyVec2D &type) { return type.y(); },
[](MyVec2D &type, float val) { type.y() = val; }));
I can't change the original class, because it's third party comes from Magnum library. Is there any better solution for it ?
There are basically multiple possible definitions and you need to choose one. You can use a static cast or a sol helper function sol::resolve to specify the one you want.
Examples:
my_vec2_type["x"] = sol::resolve<float& ()>(&MyVec2D::x);
my_vec2_type["y"] = static_cast<float&(MyVec2D::*)()>(&MyVec2D::y);
I am getting compilation error when I try to register member function x and y for MyVector class. I think it's happening because of const member function overload.
The error I am getting are
I tried multiple things to make it work, but did not work. Is there any way to register the functions MyVector2::x() ?