You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So, I'm trying to just embed squirrel language in cpp app to see how easy it is to embed or how great it is for games etc.
And to test it I tried to make a script that creates variable a (an integer). And cpp app is suposed to load that ./myscript.nut file and pull value of variable "a" form vm into stack and print it out.
(linking errors have been resolved, now there are logic errors)
here is code
#include"./squirrel_includes.h"
#include<stdio.h>
HSQUIRRELVM vm = sq_open(1024); // Create a Squirrel VMintmain() {
// Load and execute the script
SQRESULT res = sqstd_dofile(vm, "./myscript.nut", SQFalse, SQTrue);
if (SQ_SUCCEEDED(res)) {
// Get the value of variable 'a' from the scriptsq_pushinteger(vm, _SC("a"), -1);
if (SQ_SUCCEEDED(sq_get(vm, -1))) {
if (sq_gettype(vm, -1) == OT_INTEGER) {
SQInteger a;
sq_getinteger(vm, -1, &a);
printf("Value of variable 'a' in the script: %d\n", a);
} else {
printf("Variable 'a' is not an integer in the script\n");
}
} else {
const SQChar *errorString;
sq_getlasterror(vm);
sq_getstring(vm, -1, &errorString);
printf("Script execution error: %s\n", errorString);
}
} else {
const SQChar *errorString;
sq_getlasterror(vm);
sq_getstring(vm, -1, &errorString);
printf("Script execution error: %s\n", errorString);
}
sq_close(vm);
return0;
}
and when building and running app (./myscript.nut is in same directory)
and where should I ask about what's wrong? (ik chatbots are a thing but i mean like forum where ppl know what they say)?
Whould be cool if it was added to readme
The text was updated successfully, but these errors were encountered:
So, I'm trying to just embed squirrel language in cpp app to see how easy it is to embed or how great it is for games etc.
And to test it I tried to make a script that creates variable a (an integer). And cpp app is suposed to load that ./myscript.nut file and pull value of variable "a" form vm into stack and print it out.
(linking errors have been resolved, now there are logic errors)
here is code
and when building and running app (./myscript.nut is in same directory)
and where should I ask about what's wrong? (ik chatbots are a thing but i mean like forum where ppl know what they say)?
Whould be cool if it was added to readme
The text was updated successfully, but these errors were encountered: