mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-12 12:14:48 +00:00
Fixed: lua_tointeger doesn't work if value has a decimal part and returns 0
This commit is contained in:
parent
216bcc7a1c
commit
8eb174ccb3
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