🎉 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!

Register instance

Started by
1 comment, last by Kurage 10 years, 3 months ago

Hello,

I'm in trouble about registering a C++ class instance that is guaranteed to exist while the application is running.

The application instanciates the class only once then sets some correct values and keeps the instance.

I wrote some glue functions in order to accomplish my problem but none goes well.

Is there the way to register it?

Best regards,

Kurage

Advertisement

How do you want the script to access this object instance? Should it see it as a singleton object? Or should it call methods on the object as if they were global functions?

If you want the singleton object, you can register the type with the flag asOBJ_NOHANDLE, then register the object pointer with RegisterGlobalProperty.

If you want the script to call the methods as global functions you can register the object methods with RegisterGlobalFunction and using the calling convention asCALL_THISCALL_ASGLOBAL, and informing the object pointer as the last parameter.

You don't need any glue code in either of these cases, unless the object's methods needs it to translate some of the arguments or return value.

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

I want the script to access as a singleton object, and it can be done how you mentioned.

Thanks for a lot!

This topic is closed to new replies.

Advertisement