-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vector3 operator + overloading #257
Comments
Ok now I'm pretty confused, I tried using the addStaticFunction when defining the class like such:
Which in the Lua script works if I write: Seems really odd to me, but at least I'm getting closer I think. |
The exception catch is the following: attempt to perform arithmetic on a userdata value |
Have you tried:
|
@Belfer Lua follows the specific rules, citation is below. Briefly, you can only overload an arithmetic operator bound to a class instance. The @kunitoki sample does exactly that: it registers the free C++ function as an instance function. "add": the + operation. The function
By using this function, the behavior of the
|
I'm trying to get the operators for my math vec3 class into lua, consider the following line:
luabridge::getGlobalNamespace(L).addFunction("__add", (vec3(*)(const vec3&, const vec3&)) & ::operator+);
This ofc doesn't work for me, as I believe the metatable for vec3 isn't bound to the __add function above.
My problem is that it's not an option to have the operator in the class so I have to use the global operator.
Is there a way to do this?
The closest thing I could find is this issue: #117
But the post from m1k0s doesn't show the scope from which he calls addFunction.
The text was updated successfully, but these errors were encountered: