[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Calling Lua function from C
- From: Max Ischenko <max@...>
- Date: Thu, 19 Jun 2003 15:50:50 +0300
Hi,
I have a function in Lua that returns a function value:
function foobar()
return loadstring('2+3')
end
I'm trying to call the foobar from C and to save returned value (to be
able to call it later).
How am I supposed to do this?
lua_pushstring(L, "foobar");
lua_gettable(L, LUA_GLOBALSINDEX);
lua_call(L, 0, 1);
lua_tocfunction(L, -1); // returns NULL
lua_typename(L, lua_type(L, -1)); // prints "function"
Is there a way to store a Lua function as C object (and call it) or I
should be using some other way?
--
Regards, max.