[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: lua_gettable(): error check
- From: Dmitry Samoyloff <dsamoyloff@...>
- Date: Sat, 10 Apr 2004 00:22:00 +0400
Hi,
Is it possible to check in C if a requested table entry is present before
(after?) calling the lua_gettable()? I want to get the function from the
script and call it if it exists, so I'm doing the following:
lua_getglobal(LuaState, "some_func"); // The macro calling lua_gettable()
if (!lua_isfunction(LuaState, -1))
return; // No such function in the script?
int r=lua_pcall(LuaState, 0, 0, 0);
and the program crashes somewhere in lua_pcall() if the function some_func()
is absent in the script. I thought the if () statement above would avoid
this. What's wrong in my code?
Regards, Dmitry Samoyloff