Sign in to follow this  
Madcap

Passing Script Objects

Recommended Posts

Hi again,

I have one C++ class (registered as a reference in angelscript) that creates and executes a unique script which finally stores a few variables in the script object (class).  The C++ object is stored in C++ (unordered map, for now) and the C++ class stores the asIscriptobject. 

I have another class set up the same way.  This other class calls a C++ function which executes its own unique script, and in that script function it calls a C++ function to get a reference to the first C++ object. 

How would I get access within the second script to the first script object, so I can access the variables stored in that script object?

Share this post


Link to post
Share on other sites

You would have to provide a shared interface, or class, that both script modules have access to. The script object that will be passed from one module to the other should then implement that shared interface (or inherit from the shared class).

Regards,
Andreas

Share this post


Link to post
Share on other sites

Thanks.  It turns out that I can just pass the first script object to the constructor of the second object (setargobject) by it's classname in AS, which gives me direct access to the variables of that instance.  I'll just have to be careful that the first exists and figure out a way for the second to fetch the object that it needs. 

Edit: CScriptHandle and casting has made it easy to fetch a generic ref (script object) from the C++ object handle.   I think this will work.

Edited by Madcap

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this