Advanced Lua wrapper for C functions