🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

RegisterObjectMethod help

Started by
1 comment, last by lubby 11 years ago

Hi all,

I feel like a right beginner with this question. So apologies. I have had a real hard time finding concrete examples or documentation flow to learn the basics, so thus far I have struggled by - by using copy and paste from the samples and lots of trial and error.

So I am trying to register this object method


class TransformObject
{
public:
  virtual const Vector4& GetPosition() const;
}

The only way I have been successful in registering this method is as such...


RegisterObjectMethod("TransformObject", "Vector4 GetPostion() const", asMETHOD(TransformObject, GetPosition), asCALL_THISCALL); ASSERT(r>=0, "Error");

Vector4 is a class and is registered as an object type like so...


RegisterObjectType("Vector4", sizeof(Vector4), asOBJ_APP_CLASS_ALLFLOATS | asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CAK); ASSERT(r>=0, "Error");

Using scriptBuilder to build the script containing this line...


    Vector4 position = self.GetPosition();

the following errors are output


movabletest.as (18, 30) : ERR  : No matching signatures to 'TransformObject::GetPosition()'
movabletest.as (18, 25) : ERR  : Can't implicitly convert from 'const int' to 'Vector4'.

Can anyone point me to my error please. Really perplexed.

Cheers!!

Advertisement

I'm not an expert on AngelScript but looking at your code it looks like this like might be the problem


RegisterObjectMethod("TransformObject", "Vector4 GetPostion() const", asMETHOD(TransformObject, GetPosition), asCALL_THISCALL); ASSERT(r>=0, "Error");

Look at the name of the function "GetPostion", it's a typo, should be "GetPosition"

[twitter]DJ_Link[/twitter]
Blog

RegisterObjectMethod("TransformObject", "Vector4 GetPostion() const", asMETHOD(TransformObject, GetPosition), asCALL_THISCALL); ASSERT(r>=0, "Error");

Look at the name of the function "GetPostion", it's a typo, should be "GetPosition"

Expert enough to pick that up. Thanks it fixed the build script failure as you could expect. wacko.png

After passing the build script stage I have changed my registration call to exactly match the (minus the virtual) method, its still got serious issues, but I think I see what's going on now. Thank you again for the sanity check!

This topic is closed to new replies.

Advertisement