Advertisement

Having problems registering functions

Started by February 18, 2009 08:14 PM
1 comment, last by IndependentHat 16 years ago
So I started using angelscript a few days ago... Been trying to register some math classes that work with the physics engine im using and I ran into a few problems. First, I have a few math classes that contain arrays. How can I access them in ASCRIPT without helper functions? like vector.v[1]? Second, I tried to get around this using the operator[]. r = g_ascript_engine->RegisterObjectBehaviour("neV3", asBEHAVE_INDEX, "float f(int) const", asMETHODPR(neV3,index,(int),neV3&), asCALL_THISCALL); assert( r >= 0 ); It runs the index function fine but thats really just a crappy fix. I can't get asMethodPR to compile with operator[] as the function to call. It worked for other operators like operator+=. Maybe it doesn't like the []? Is there a way around this? I dont know how to get my own function pointer without using that macro thing you got. Any help you could give would be awesome-o.
There's no secret to the operator[], you should be able to take the address of it just like any other operator. Perhaps you can share the compilation error and the declaration you have for the operator?

r = g_ascript_engine->RegisterObjectBehaviour("neV3", asBEHAVE_INDEX, "float f(int) const", asMETHODPR(neV3,operator[],(int) const, float), asCALL_THISCALL); assert( r >= 0 );


The registration that you showed us seems to be wrong. You register the operator to return a float by value, but the function pointer is for a method that returns a neV3 by reference. Unless you just typed this wrong when posting here, you'll need to change that or you'll most likely encounter application crashes.

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
Wow, cant believe I missed that typo! Now I feel dumb.

Thanks for quick response, it fixed it.

This topic is closed to new replies.

Advertisement