Skip to main content
GameDev.net gamedev.net
🔒 Locked

Passing Script Objects

Started by Madcap Oct 7, 2017 at 1:37 PM 2 replies 2.5k views
Original Post
Madcap
Madcap

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?

WitchLord
WitchLord

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 - <a href="http://www.angelcode.com/tower" rel
Madcap
Madcap

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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.