I have a new problem that i am unable to figure out.
this is the code:
ASEngine = asCreateScriptEngine(ANGELSCRIPT_VERSION); ASEngine->AddScriptSection("module", "section", Script, ScriptLength, m_lPrevScriptLength); COutStream out; int a = ASEngine->Build("module", &out);
these are the errors, and follwing the errors, is the script
section (564, 2) : Error : Unexpected token 'for'
section (564, 20) : Error : Expected identifier
section (564, 27) : Error : Expected identifier
//void main(void)//{ int sum = 0; for (int i = 0; i < 10; i++) { sum += i; //m_PlayerX = sum; //UpdateData(0); }//}
EDIT-->
I appear to have corrected the problem by changing the scriptto something along these lines:
int sum1(int a, int b){ return a+b;}void main(){ for (int i = 0; i < 10; i++) { sum +=sum1(sum,i); m_PlayerStatus = sum; //UpdateData(0); }}
and using the following code:
ASEngine = asCreateScriptEngine(ANGELSCRIPT_VERSION); ASEngine->RegisterGlobalProperty("int sum", ∑); ASEngine->RegisterGlobalProperty("const int m_PlayerStatus", &m_PlayerStatus); ASEngine->RegisterGlobalProperty("const float m_PlayerHeading", &m_PlayerHeading); ASEngine->AddScriptSection(0, "section", Script, strlen(Script), m_lPrevScriptLength); COutStream out; int a = ASEngine->Build(0, &out); ASEngine->CreateContext(&ASCtx); ASCtx->Prepare(ASEngine->GetFunctionIDByDecl(0, "void main()")); int r = ASCtx->Execute();
[Edited by - Rain Dog on October 17, 2004 12:21:04 AM]