Advertisement

Multiple object arguments problem

Started by February 10, 2014 05:07 AM
1 comment, last by WitchLord 10 years, 9 months ago

I am currently getting some issues with compiling my script

AngelScript:


int SpellFire(BaseEntity& spell, BaseEntity& cast, BaseEntity& trg){
return 0;
}
C++ call and BaseEntity registry

Register
void RegisterBaseEntityAngel(asIScriptEngine *engine){
// Registering the class method
int r = engine->RegisterObjectType("BaseEntity", sizeof(BaseEntity), asOBJ_REF); DYNAMIC_ASSERT(r >= 0, "Error in return result");
r = engine->RegisterObjectBehaviour("BaseEntity", asBEHAVE_ADDREF, "void f()", asMETHOD(BaseEntity, AddRef), asCALL_THISCALL); DYNAMIC_ASSERT(r >= 0, "Error in return result");
r = engine->RegisterObjectBehaviour("BaseEntity", asBEHAVE_RELEASE, "void f()", asMETHOD(BaseEntity, Release), asCALL_THISCALL); DYNAMIC_ASSERT(r >= 0, "Error in return result");
Init
ctx = scriptMgr.GetEngine()->CreateContext();
asIScriptModule *mod = scriptMgr.GetEngine()->GetModule("SpellFuncs");
Function = mod->GetFunctionByDecl(Str8(Stat("Script")->string));
update
ctx->Prepare(Function); 
ctx->SetArgObject(0, &T);// Set the function arguments 
ctx->SetArgObject(1, cast);// Set the function arguments 
ctx->SetArgObject(2, trg);// Set the function arguments 
scriptMgr.ExecuteCall(ctx); 
int dmg = ctx->GetReturnDWord(); 
ctx->Unprepare();

Log complaints


Data/Script/Spells/Fire.as (1, 46) : ERROR:  : Expected ')' or ','Please correct the errors in the script and try again.  (0, 0) : ERROR:  : Failed in call to function 'Prepare' with 'null' (Code: -6)  (0, 0) : ERROR:  : Failed in call to function 'Execute' (Code: -4)

Anyone care to explain what I am doing wrong?

I've tried removing and changing @ to & and without sign

It works if I am using only one BaseEntity.

I found that I could not use cast as a argument name, I thought cast would be with Capital c rather than non capital.

Advertisement

The reserved keywords are the ones listed here: http://www.angelcode.com/angelscript/sdk/docs/manual/doc_reserved_keywords.html

However, I'll see if I can make the error message a bit more clear. For example, it could mention that the 'cast' wasn't expected at this position.

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