🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Vector of any

Started by
0 comments, last by WitchLord 15 years, 10 months ago
Hi! As I need a generic array in AngelScript my idea was to register the stl vector with any as type using CScriptAny and RegisterVector.

RegisterArray<CScriptAny*>("any[]", "any", engine);

...

class Point2D
{
    Point2D(float pX, float pY)
    {
        mX=pX;
        mY=pY;
    }

    float mX;
    float mY;
}

void test()
{
    any[] tAny;
    for (int i=0; i<10; ++i)
    {
        Point2D tPoint(i*10.0f, 0.0f);
        tAny.push_back(any(@tPoint));
    }

    for (int j=0; j<10; ++j)
    {
        Point2D @tPoint;
        tAny[j].retrieve(@tPoint);
        print(toString(tPoint.mX)+"\n");
    }
}

However this seems to work at the first moment but after a few tests my application sometimes crashed. When it didn't crash the print doesn't work as well. Did someone similar things with CScriptAny or are there other solutions to this problem? Verge
Advertisement
I believe you need to register the vector as:

RegisterArray<CScriptAny*>("any@[]", "any@", engine);



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

This topic is closed to new replies.

Advertisement