🎉 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!

[SOLVED] Passing object handle to array::insertLast

Started by
1 comment, last by WitchLord 5 years, 7 months ago

I have a type registered as so:


    ScriptEngine->RegisterObjectType("Object",0,asOBJ_REF|asOBJ_NOCOUNT);

Then in my script I have this code:


array<Object@> ret = {};
const Object@ x = @game.objects[i];
ret.insertLast(x);

Which gives the error:


ai\9.as(162, 13): ERROR : No matching signatures to 'array::insertLast(const Object@&)'
ai\9.as(162, 13): INFORMATION : Candidates are:
ai\9.as(162, 13): INFORMATION : void array::insertLast(Object@const&in)

What does this mean? What's the difference between const Object@ and Object@const?

I'm sorry I don't know offhand what version of Angelscript I'm using, because someone else compiled it for me a few years ago.

Advertisement

Your array is expecting handles to objects that are modifiable, i.e. not const. But you're trying to insert a handle to a non-modifiable object, i.e. const.

'const Object @' is a handle to non-modifiable object.

'Object @const' is a handle to a modifiable object, only the handle itself cannot be changed to refer to a different object.

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

This topic is closed to new replies.

Advertisement