lua-users home
lua-l archive

executing functions from file, without using luaL_dofile

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello,
I'm trying to load a Lua script from a C file, without executing it at load time.
In other words, i don't want to use "luaL_dofile (L, script.lua)".
So i use instead "luaL_loadfile (L, "script.lua") "
But after loading the script file, how can i execute "foo" function from inside it ?
i tried this:
 lua_getglobal(L, "foo");
 lua_pcall (L,0,0,0); //compile function
 lua_getfield (L, LUA_GLOBALSINDEX,"foo");
 lua_pcall (L, 0,0,0); //execute function
but the function is not executed.
Thank you.

AltStyle によって変換されたページ (->オリジナル) /