mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-10 09:19:01 +00:00
Fixed: lua_tointeger doesn't work if value has a decimal part and returns 0
This commit is contained in:
parent
adb1cbf4bc
commit
5b01b79a4c
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)
|
||||
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