Advertisement

There is no copy operator...

Started by December 21, 2010 10:09 AM
2 comments, last by WitchLord 13 years, 11 months ago
Hi,

I have this AngelScript class that I want to use a basis for various script-classes:
class ScriptActor{	void init(Actor @actor)	{		m_actor = actor;	}	Actor @m_actor;};

Actor is a reference type that I registered with AngelScript. However, when this init function is called I get an error that tells me that no copy operator is assigned for that data type.
I don't want to copy anything, just store a handle to the actor, so that I can use it later.
If I just access methods of Actor inside the script-function it works.

Any idea what I should do in this case?
You need to do a handle assignment by prepending the left expression with the @ symbol. Without the symbol it is a value assignment, for which the copy operator (opAssign method) is needed.

class ScriptActor{	void init(Actor @actor)	{		// Do handle assignment		@m_actor = actor;	}	Actor @m_actor;};

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

Advertisement
Ok, thanks for the answer!

Seems that I need to look into the syntax of AS a little more.
I was under the impression, that Type @ is kind of like a pointer. So if I copy the value from one pointer to another, the actual data behind it is not copied.
It is more like a C++ reference than a pointer in that regard, except that the handle can be reassigned, which the C++ reference cannot.

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