#70881 - TwinD - Thu Feb 09, 2006 7:00 am
Ok
I have a fairly flexible engine that has been built on for awhile. Originally I was just doing the scripting using C but recently decided to change over to LUA. I use GBFS and seeing as they aren't 'real' files in GBFS I figured I have to use lua_dobuffer instead of lua_dofile so i have a compiled lua file in my GBFS named mithla.lub
my loading code:
u32 size;
const char* scriptFile = (const char*)gbfs_get_obj(dat, filename, &size);
lua_dobuffer(luaScript, scriptFile, size, filename);
then to call the autoexec (the one thing im testing)
runFunction("autoexec");
// runs a function in the current script
void CScriptHandler::runFunction(char *funcname)
{
int top = lua_gettop(luaScript);
lua_getglobal(luaScript, funcname);
lua_call(luaScript, 0, 0);
lua_settop(luaScript, top);
}
the lua file has:
-- Test Script File for GBA Engine
function autoexec ()
loadMap("Mithla Village");
end
loadMap right now is a hacked function that loads the same map everytime, sets everything up and puts it on screen for testing purposes
ive made sure im initializing the luaVM, registering all my functions, loading the right file, checked that its in the gbfs, etc but im not seeing the problem and it just isnt doing anything when it calls the autoexec
any ideas?
I have a fairly flexible engine that has been built on for awhile. Originally I was just doing the scripting using C but recently decided to change over to LUA. I use GBFS and seeing as they aren't 'real' files in GBFS I figured I have to use lua_dobuffer instead of lua_dofile so i have a compiled lua file in my GBFS named mithla.lub
my loading code:
u32 size;
const char* scriptFile = (const char*)gbfs_get_obj(dat, filename, &size);
lua_dobuffer(luaScript, scriptFile, size, filename);
then to call the autoexec (the one thing im testing)
runFunction("autoexec");
// runs a function in the current script
void CScriptHandler::runFunction(char *funcname)
{
int top = lua_gettop(luaScript);
lua_getglobal(luaScript, funcname);
lua_call(luaScript, 0, 0);
lua_settop(luaScript, top);
}
the lua file has:
-- Test Script File for GBA Engine
function autoexec ()
loadMap("Mithla Village");
end
loadMap right now is a hacked function that loads the same map everytime, sets everything up and puts it on screen for testing purposes
ive made sure im initializing the luaVM, registering all my functions, loading the right file, checked that its in the gbfs, etc but im not seeing the problem and it just isnt doing anything when it calls the autoexec
any ideas?