Advertisement

Passing Script Objects

Started by October 07, 2017 01:37 PM
2 comments, last by Madcap 7 years, 1 month ago

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?

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

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

Advertisement

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.

This topic is closed to new replies.

Advertisement