So, I want to make a function that takes a string like, for example, "return 1+1", and returns the result. I have a function that runs strings as code already:
Code:
SQInteger sqDoString(HSQUIRRELVM v) {
const char* a;
sq_getstring(v, 2, &a);
SQInteger oldtop = sq_gettop(gvSquirrel);
sq_compilebuffer(gvSquirrel, a, (int)strlen(a) * sizeof(SQChar), "string", 1);
sq_pushroottable(gvSquirrel);
sq_call(gvSquirrel, 1, SQFalse, SQTrue);
sq_settop(gvSquirrel, oldtop);
return 0;
}
The issue here is that simply setting SQFalse to SQTrue and returning 1 didn't work; this just results in it returning the same string it was given as an argument. What do I do to make it return what the string function returns?