How to find out whether there is a specific key for a given Lua table through C Apis?
I know that traversing the whole table could achieve this goal, but it's not an efficient method. Is there any better method?
The function you want is lua_gettable.
First, push the table, then the key you want to check. Then you should be able to do gettable(L, -2) != LUA_TNIL.
Simply check if yourtable[yourkey] is nil
You always put a key-value pair into a table. No value, no key.