Hi, I was hoping to get some help regarding script reloading.
I would like my scripts to be reloaded on demand to allow for the scripts to be edited and 'refreshed' at runtime.
However, I can't seem to be able to unload the previous script and reloading the script still reflects the old one before editing.
Here is the code I've used:
Code:
// Loading the script.
int top = sq_gettop(vm);
if(SQ_SUCCEEDED(sqstd_loadfile(vm, file, true))) {
sq_getstackobj(vm,-1,&obj);
sq_addref(vm, &obj);
sq_settop(vm,top);
}
// Run the script to register the functions
if(!sq_isnull(obj)) {
int top = sq_gettop(vm);
sq_pushobject(vm, obj);
sq_pushroottable(vm);
if(SQ_SUCCEEDED(sq_call(vm, 1, false, true))) {
sq_settop(vm,top);
}
}
// Unload the script
sq_release( vm, &obj );
I'm not sure if I'm doing anything wrong, but when I try to load the same file again after unloading, it still uses the old scripting code, as if I never reloaded it.
I would greatly appreciate any help or advice!
Thanks!
EDIT: Forgot to mention that I'm using Squirrel 2.2.4.