I'm trying to use my own Vector class and am running into issues.
I have two functions in my Vector class that allow it to multiple with a float in any order like this.
friend Vector operator+ (const Vector& t, float f) {return Vector(t.x+f,t.y+f,t.z+f);}
friend Vector operator+ (float f, const Vector& t) {return Vector(t.x+f,t.y+f,t.z+f);}
I don't know how to register this with AngelScript so that I can multiple a Vector with a float in any order. I've tried registering it like this, but it gives an error that it failed to register the second function. I'm guessing because I've declared opMul already with the same declaration?
engine->RegisterObjectMethod("Vector", "Vector opMul(float f)", asFUNCTIONPR(operator*, (const Vector&, float), Vector), asCALL_CDECL_OBJFIRST);
engine->RegisterObjectMethod("Vector", "Vector opMul(float f)", asFUNCTIONPR(operator*, (float, const Vector&), Vector), asCALL_CDECL_OBJLAST);
If I comment out either line above, so I'm only registering one of the functions (doesn't matter which one), then it works in script in the order of Vector * float. But it fails if I try to do float * Vector. I get an error that says "No conversion from 'Vector' to math type available."
How can I set up my Vector class so I can multiply if by a float in any order, i.e. Vector * float or float * Vector?