Jump to content
  • Advertisement
Sign in to follow this  
Madcap

Passing Script Objects

This topic is 437 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 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
Advertisement

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
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!