How do I add class instance to list/vector in chai script?

73 views Asked by At

How can i put an instance of a sprite in a list in chaiscript like this:

global Vaxskivling = Sprite("/resources/textures/Vaxskivling.png");
var list = [Vaxskivling];

When doing this i receive the following error:

Error: "Can not find appropriate 'clone' or copy constructor for vector elements

i have added the class constructor and type:

    chai->add(chaiscript::base_class<Renderable, Sprite>());
    chai->add(chaiscript::user_type<Sprite>(), "Sprite");
1

There are 1 answers

0
J.Wennergren On

I had a unique_ptr reference in my interface "Renderable" which Sprite implements. I changed to shared_ptr plus using this constructor:

chai.add(chaiscript::constructor<MyType (const MyType &)>(), "MyType");

my issue was resolved!