Jump to content
  • Advertisement
Sign in to follow this  
mboeni

AS in-game console

This topic is 2946 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 all

I want to use AS in my in-game console (using Ogre3D 1.7.1 on Win7, MSVC 10) and have the problem of persistent assertion errors (Assertion Failed) where i do not really understand why.

I am using a console and pas the engine to an 'initBindings' method like so:

void ASBindings::initBindings(asIScriptEngine *engine)
{
int retVal;
retVal = engine->RegisterObjectMethod("test", "void bindingTest()", asMETHOD(ASBindings,bindingTest), asCALL_STDCALL); assert(retVal >= 0);
}

The registerObjectMethod method causes the issue but i dont see my error.

The test method is very simple:
void ASBindings::bindingTest()
{
std::cout << "****** W00000T *****\b";
}

Could anyone point out what I'm doing wrong?

Share this post


Link to post
Share on other sites
Advertisement
tried that:

//does the actual binding
void ASBindings::initBindings(asIScriptEngine *engine)
{
int retVal;
retVal = engine->RegisterObjectMethod("test", "void bindingTest()", asMETHOD(ASBindings,bindingTest), asCALL_THISCALL); assert(retVal >= 0);
}

Same issue still though.

Share this post


Link to post
Share on other sites
yes, its the only binding.

The test class is "ASBindings" as defined here:

class ASBindings
{
public:
ASBindings(void);
virtual ~ASBindings(void);

static void initBindings(asIScriptEngine *engine);
void bindingTest(void);
static void staticTest(void);

int testVar;

protected:

};

Do I have to register the class separately? I was assuming that this is implicit with the registration of the method (the class name is one parameter).

Share this post


Link to post
Share on other sites
The class has to be registered separately. Without the class registration AngelScript won't know if it's a value type or reference type or other behaviors specific to the class type.

Share this post


Link to post
Share on other sites
Can you make an example or point to one? Going through the tutorials i haven't found a reference to that...

Thanks,
Michael

Share this post


Link to post
Share on other sites

//does the actual binding
void ASBindings::initBindings(asIScriptEngine *engine)
{
int retVal;
retVal = engine->RegisterObjectType("test", sizeof(ASBindings), asOBJ_VALUE | asOBJ_APP_CLASS_CD); assert(retVal >= 0);
retVal = engine->RegisterObjectMethod("test", "void bindingTest()", asMETHOD(ASBindings,bindingTest), asCALL_THISCALL); assert(retVal >= 0);
}


If you get an error from the registration functions, always check the return value. In your case you probably got asINVALID_TYPE (-12), which would have told you that the object type is incorrect.

You should also set the message callback to get more descriptive error messages. The message callback is not only used for compiler errors but may also provide useful hints during the registration of types and functions.

Message callback

Regards,
Andreas

Share this post


Link to post
Share on other sites
One hurdle taken :) no more assertion failures.

I definitely wouldn't have come up with your solution...

Thanks Andreas!

Cheers,
Michael

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!