Search code examples
c++bindingluabindluabridge

How do I use operators in LuaBridge


I'm trying to export my vectors class

            .beginClass<Vector>("Vector")
            .addConstructor<void(*)()>()
            .addConstructor<void(*)(float, float, float)>()
            .addFunction("__eq", &Vector::operator==)
            .addFunction("__add", &Vector::operator+)
            .addData("x", &Vector::x)
            .addData("y", &Vector::y)
            .addData("z", &Vector::z)
            .addFunction("Length", &Vector::Length)
            .addFunction("Angle", &Vector::Angle)
            .addFunction("Distance", &Vector::DistTo)
        .endClass()

but when i try and do the other 3 operators, I have multiple overloads for them. How can I specify which one I want to use and is this even possible?


Solution

  • So I just made an add/subtract/multiply/divide function and called that instead. Guess operators just don't want to comply.