> In some situation of lua_tointeger(lua, 1) i take wrong values or 0
> Not sure at moment what the problem it is.
A 0 can mean that the value at that position is not an integer (that
is, it is a float with a fractional part). You may want to compile Lua
defining the macro LUA_FLOORN2I (-DLUA_FLOORN2I) to see whether it
helps. (That macro makes Lua convert non-integer floating points to
integers by taking their floor.)