Sorry for creating so many threads recently. I've got some kind of chicken and egg problem.
There's a class "EffectC" implemented in C++ and also an angelscript class "Effect" which is loaded in a "base" module. When EffectC is created, it creates an instance of "Effect" which has a constructor, taking EffectC as parameter:
shared class Effect : DynamicBase, Object
{
private EffectC@ self;
Effect(EffectC@ obj) { @self = obj; }
//...
}
Now here's the problem: In Angelscript I'd like to create a new effect, calling a globalFunction "Effect@ createEffect()". This should actually be a registered C++ function, that creates "EffectC", which in turn creates an instance of "Effect" and returns it.
r = engine->RegisterGlobalFunction("Effect@ createEffect(uint res)", asFUNCTION(asCreateEffect), asCALL_CDECL);
This doesn't work, obviously, because the engine doesn't know about "Effect" (identifier "Effect" is not a data type).
Is it even possible to use a C++ function and return an asIScriptObject?