I'm testing out a rudimentary AngelScript console, and am running into a problem with it.
It has to do with how asCScriptEngine::ExecuteString is implemented.
Right now I want to be able to do something like this (I have registered the string type and print() function):
AngelScript Console 0.1 (AS Ver: 1.10.1b)
>> string test = "Hello, World!\n";
>> print(test);
This does nothing at the moment, because my console loop looks like this (pseudo-code):
string line;
while(1)
{
getline(cin,line);
if(!cin)
break; // Use CTRL+Z to exit
pEngine->ExecuteString("as_console",line.c_str());
}
Now, I'm pretty sure the reason this
doesn't work is because of how asCScriptEngine::ExecuteString works: It wraps the string in a "void ExecuteString() {\n" + str + "}" script chunk.
This turns the above line
string hello = "Hello, World!\n"; into a local variable, which isn't found in the subsequent call to print(hello);
Is there anything way to create a variable in one call to ExecuteString() and then reference it in another call?
Or am I completely missing how AngelScript works?