Hi,
I am having a problem getting AS working again. I keep getting the message "Object handle is not supported for this type", or the program crashes.
This only happens with "array<uint>" or "array<Color>". The "array<wstring>" works find and returns what it is expected. Is the color or uint that does not return ok, script fails to compile.
Thanks in advance for any help. Let me know if you guys need more info.
Here is the code:
Script Code:
array<ScriptConsoleLine> crlArr;
array<wstring> line;
array<Color> color;
wstring ukcmmd = m_LocalizationManager.GetLiteral("XE_CONSOLE_MSG_UNK_CMD") + ":";
line.insertLast(ukcmmd);
color.insertLast(GetColorByEnum(XEColorType_Red));
line.insertLast(subCommands[0]);
color.insertLast(GetColorByEnum(XEColorType_White));
ScriptConsoleLine crl;
@crl.m_SA_Strings = line;
@crl.m_SA_Colors = color; //<----- Always fails here, states "Object handle is not supported for this type" for either array<uint> or array<Color>
crlArr.insertLast(crl);
@m_ScriptConsoleLineArray = crlArr;
Struct Code
struct ScriptConsoleLine sealed : public XEObject
{
CScriptArray* m_SA_Strings;
CScriptArray* m_SA_Colors;
//Contructor
ScriptConsoleLine()
: m_SA_Strings(nullptr)
, m_SA_Colors(nullptr)
{
}
ScriptConsoleLine(const ScriptConsoleLine& other)
{
*this = other;
}
virtual ~ScriptConsoleLine()
{
ReleaseAngel(m_SA_Strings);
ReleaseAngel(m_SA_Colors);
}
ScriptConsoleLine& operator=(const ScriptConsoleLine& other)
{
ReleaseAngel(m_SA_Strings);
ReleaseAngel(m_SA_Colors);
if (other.m_SA_Strings != nullptr)
{
m_SA_Strings = other.m_SA_Strings;
other.m_SA_Strings->AddRef();
}
if (other.m_SA_Colors != nullptr)
{
m_SA_Colors = other.m_SA_Colors;
other.m_SA_Colors->AddRef();
}
return *this;
}
static void Constructor(ScriptConsoleLine* self)
{
new(self) ScriptConsoleLine();
}
static void Destructor(ScriptConsoleLine* self)
{
self->~ScriptConsoleLine();
}
};
AS Code to register Struct
ret = asManager->GetASEngine()->RegisterObjectType("ScriptConsoleLine", sizeof(ScriptConsoleLine), asOBJ_VALUE | asOBJ_APP_CLASS);
...//Checks for ret
ret = asManager->GetASEngine()->RegisterObjectProperty("ScriptConsoleLine", "array<wstring>@ m_SA_Strings", asOFFSET(ScriptConsoleLine, m_SA_Strings));
...//Checks for ret
ret = asManager->GetASEngine()->RegisterObjectProperty("ScriptConsoleLine", "array<Color>@ m_SA_Colors", asOFFSET(ScriptConsoleLine, m_SA_Colors));
...//Checks for ret
ret = asManager->GetASEngine()->RegisterObjectMethod("ScriptConsoleLine", "ScriptConsoleLine &opAssign(const ScriptConsoleLine& in)", asMETHOD(ScriptConsoleLine, operator=), asCALL_THISCALL);
...//Checks for ret
ret = asManager->GetASEngine()->RegisterObjectBehaviour("ScriptConsoleLine", asBEHAVE_CONSTRUCT, "void XEAS_ScriptConsoleLineConstructor()", asFUNCTION(ScriptConsoleLine::Constructor), asCALL_CDECL_OBJLAST);
...//Checks for ret
ret = asManager->GetASEngine()->RegisterObjectBehaviour("ScriptConsoleLine", asBEHAVE_DESTRUCT, "void XEAS_ScriptConsoleLineDestructor()", asFUNCTION(ScriptConsoleLine::Destructor), asCALL_CDECL_OBJLAST);
...//Checks for ret
ret = asManager->GetASEngine()->RegisterGlobalProperty("array<ScriptConsoleLine> @m_ScriptConsoleLineArray", &m_ScriptConsoleLineArray);
...//Checks for ret
if(asManager->LoadScript(".\\Data\\Scripts\\Console.as", m_ConsoleModuleName) != XEResult
...//Loads script and checks for ret