[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Determine if function is defined with C API?
- From: "Jerome Vuarand" <jerome.vuarand@...>
- Date: Fri, 1 Aug 2008 18:09:03 +0200
2008/8/1 Joey Mukherjee <joey@swri.edu>:
> Here's a snippet of my code:
>
> lua_getglobal (LState, "get_number_of_sensors"); //
> function to be called
> if (lua_isfunction (LState, 0) == 1) {
> if (lua_pcall (LState, 0, 1, 0) == 0) {
>
> This doesn't work. Is it because I don't have the right index? I am
> assuming the lua_getglobal either found the function or if it didn't, how
> would I know? How do I find the right index to send to lua_isfunction?
lua_getglobal pushes the global on the top of the stack. The index of
the top of the stack is either -1 or lua_gettop(L). That is the value
you should pass to lua_isfunction.