[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Calling a function defined in lua from C/C++
- From: Turgut Hakki Ozdemir <extronus@...>
- Date: Wed, 10 May 2006 21:39:40 +0300
Greetings,
lua_call(L, 0, 0); // when i use lua_pcall instead of lua_call here,
surrounded with error handling functionality it complains about nil values
lua_close(L);
}
After loading the test.lua file, you must run it because it's
just a function on the stack at this point. After running it your
declarations will have effects.
Does'nt lua_*call functions do it?
------------------------ some lua code ----------------------
function funk()
end
--- If the body of script does not have any code it works
------------------------ some c code -------------------------
luaL_loadfile(L, "test.lua"); // Ok
lua_call(L, 0, 0); // Works as expected with 1st script (does nothing)
2nd script fails here
// My first message does not contains following since it failed above
lua_getglobal(L, "funk"); // funk is on top of the stack?
lua_call(L, 0, 0); // Ok, funk being called
------------------------ end of some c code ------------
but... when i run above code with this script, int msg(lua_State *L);
function gets 0x0 as function address
------------------------ another lua code ---------------
function funk()
end
msg(funk) -- msg will fail to receive address
----------------------------------------------------------------------
so lua scripts can't register their functions as callbacks :)