Getting an error when it tries to compile the angelscript module:
Heres the variable class:
void RegisterScriptVariable(asIScriptEngine *engine){ int r = 0; // Register the type r = engine->RegisterObjectType("var", sizeof(Variable), asOBJ_VALUE | asOBJ_APP_CLASS_CDA); assert( r >= 0 ); // Register the constructors r = engine->RegisterObjectBehaviour("var", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(VariableDefaultConstructor), asCALL_CDECL_OBJFIRST); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("var", asBEHAVE_CONSTRUCT, "void f(int)", asFUNCTION(VariableIntConstructor), asCALL_CDECL_OBJFIRST); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("var", asBEHAVE_CONSTRUCT, "void f(float)", asFUNCTION(VariableFloatConstructor), asCALL_CDECL_OBJFIRST); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("var", asBEHAVE_CONSTRUCT, "void f(const var& in)", asFUNCTION(VariableCopyConstructor), asCALL_CDECL_OBJFIRST); assert( r >= 0 ); //Register the destructor r = engine->RegisterObjectBehaviour("var", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(VariableDestructor), asCALL_CDECL_OBJFIRST); assert( r >= 0 ); //Register the casting (Variable should be able to cast to int, float and string) r = engine->RegisterObjectBehaviour("var", asBEHAVE_IMPLICIT_VALUE_CAST, "int f()", asFUNCTION(VariableCastInt), asCALL_CDECL_OBJFIRST); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("var", asBEHAVE_IMPLICIT_VALUE_CAST, "float f()", asFUNCTION(VariableCastFloat), asCALL_CDECL_OBJFIRST); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("var", asBEHAVE_IMPLICIT_VALUE_CAST, "string@ f()", asFUNCTION(VariableCastString), asCALL_CDECL_OBJFIRST); assert( r >= 0 ); //Register the assignment operator r = engine->RegisterObjectBehaviour("var", asBEHAVE_ASSIGNMENT, "var& f(const var& in)", asMETHODPR(Variable, operator=, (const Variable&), Variable&), asCALL_THISCALL); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("var", asBEHAVE_ASSIGNMENT, "var& f(const string& in)", asMETHODPR(Variable, operator=, (const std::string&), Variable&), asCALL_THISCALL); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("var", asBEHAVE_ASSIGNMENT, "var& f(int)", asMETHODPR(Variable, operator=, (int), Variable&), asCALL_THISCALL); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("var", asBEHAVE_ASSIGNMENT, "var& f(float)", asMETHODPR(Variable, operator=, (float), Variable&), asCALL_THISCALL); assert( r >= 0 );}
Here's the angelscript module that will not compile. The error happens when it tries to cast from "var" to "string". This script works fine if i try to cast from "var" to "float" or "int".
//#Server core script (REQUIRED)var derp = "blah";void main(){ string test = derp; Print(test);}
Here's the error:
Loading plugins... (6, 1) : INFO : Compiling void main() (8, 17) : ERR : Found more than one matching operatorUnable to load plugin: Server
EDIT: Another problem. This returns an error (-7)
r = engine->RegisterObjectBehaviour("var", asBEHAVE_IMPLICIT_VALUE_CAST, "bool f()", asFUNCTION(VariableCastBool), asCALL_CDECL_OBJFIRST);
I wanted to register the bool operator so i could do:
var myVar = 1;if(myVar){}
That script doesn't work :(
[Edited by - 39ster on April 16, 2009 12:47:54 AM]