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

How to define functions that return script object types?

Started by
0 comments, last by WitchLord 9 years, 10 months ago

Hello,

I'm trying to expose my application interface to angelscript using class wrappers. I'm doing so to allow further inheritance in script sources. Basically what I'm doing is this:

First, I'm registering a C++ class, say 'MyObject', as 'NativeMyObject'.

Then, I add a script section to my global module:


class MyObject : NativeMyObject
{
... // wrap all the methods and stuff of the 'real' MyObject.
}

Right after that I build the module.

What I want to do next is registering a global function that returns a MyObject (not NativeMyObject!). This however seems to be impossible due to MyObject no being know to the global namespace.

Is there any way to get around this issue? I guess the idea of having derivable script classes from native C++ classes may be very common and I'm just doing something wrong here.

Any help ist greatly appreciated!

Advertisement

There are basically two options.

Either you return the MyObject script class in a generic container (e.g. the ref add-on type), or you register a script interface that MyObject needs to implement too, and then register the method to return the script class as that interface.

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

This topic is closed to new replies.

Advertisement