• Advertisement
Sign in to follow this  

Reference object with properties

This topic is 2195 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

I have a Npc class like this


class Npc
{
public:
int hp;
int Jump();
}


i dont want to register it as value since Ai module handles all npc objects. i wont create or destroy any npc objects in AngelScript neither.

i just want to pass around this npc pointer between c++ and angelscipt, with no garbage collecting.

i do something like this;


r = engine->RegisterObjectType("Npc", 0, asOBJ_REF | asOBJ_NOCOUNT); assert( r >= 0 );
r = engine->RegisterObjectProperty("Npc", "int hp", asOFFSET(Npc, hp)); assert( r >= 0 );
r = engine->RegisterObjectMethod("Npc", "int Jump()", asMETHOD(Npc,Jump), asCALL_THISCALL);assert( r >= 0 );


second line causes assertion: "Failed in call to Function RegisterObjectProperty".

what is the correct way of registering class properties in reference objects?

thank you.

edit:
fixed. i was using unsigned int :( (should be uint)
i have been looking this line for an hour but couldnt see my obvious mistake

Share this post


Link to post
Share on other sites
Advertisement
Hi saejox,

I'm glad you figured out the problem on your own.

However, I'll see if I can make the error message returned by AngelScript be more explicit to reduce the time to identify the problem. Thanks for the report.

Regards,
Andreas

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement