mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-23 07:36:16 +00:00
Fixed: lua_tointeger doesn't work if value has a decimal part and returns 0
--HG-- branch : develop
This commit is contained in:
parent
7104a6cb29
commit
49ef5a1ed7
1 changed files with 9 additions and 1 deletions
|
@ -253,7 +253,15 @@ inline lua_Integer CLuaState::toInteger(int index)
|
||||||
{
|
{
|
||||||
//H_AUTO(Lua_CLuaState_toInteger)
|
//H_AUTO(Lua_CLuaState_toInteger)
|
||||||
checkIndex(index);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
//================================================================================
|
//================================================================================
|
||||||
|
|
Loading…
Reference in a new issue