lua_Integer lua_tointeger (lua_State *L, int idx);

Converts the Lua value at the given acceptable index to the signed integral type lua_Integer. The Lua value must be a number or a string convertible to a number (see Coercion); otherwise, lua_tointeger returns 0.

If the number is not an integer, it is truncated in some non-specified way.