diff --git a/code/nel/include/nel/gui/lua_helper_inline.h b/code/nel/include/nel/gui/lua_helper_inline.h index 68721cfaa..df75e6b5b 100644 --- a/code/nel/include/nel/gui/lua_helper_inline.h +++ b/code/nel/include/nel/gui/lua_helper_inline.h @@ -253,7 +253,15 @@ inline lua_Integer CLuaState::toInteger(int index) { //H_AUTO(Lua_CLuaState_toInteger) checkIndex(index); - return lua_tointeger(_State, index); + sint isnum = 0; + lua_Integer res = lua_tointegerx(_State, index, &isnum); + if (!isnum) + { + lua_Number d = lua_tonumber(_State, index); + nlwarning("Lua: Unable to convert Lua number %lf to integer", d); + res = (lua_Integer)d; + } + return res; } //================================================================================