diff --git a/modules/core_lib/util.lua b/modules/core_lib/util.lua index f231b902..23234de7 100644 --- a/modules/core_lib/util.lua +++ b/modules/core_lib/util.lua @@ -79,7 +79,6 @@ end local oldtonumber = tonumber function tonumber(v) - local v = oldtonumber(v) - if not v then return 0 end - return v + if v == nil then return 0 end + return oldtonumber(v) end diff --git a/src/framework/luascript/luavaluecasts.cpp b/src/framework/luascript/luavaluecasts.cpp index cb9065ee..352a4b6b 100644 --- a/src/framework/luascript/luavaluecasts.cpp +++ b/src/framework/luascript/luavaluecasts.cpp @@ -45,8 +45,8 @@ void push_luavalue(int i) bool luavalue_cast(int index, int& i) { i = g_lua.toInteger(index); - //if(i == 0 && !g_lua.isNumber(index)) - // return false; + if(i == 0 && !g_lua.isNumber(index) && !g_lua.isNil()) + return false; return true; } @@ -59,8 +59,8 @@ void push_luavalue(double d) bool luavalue_cast(int index, double& d) { d = g_lua.toNumber(index); - //if(d == 0 && !g_lua.isNumber(index)) - // return false; + if(d == 0 && !g_lua.isNumber(index) && !g_lua.isNil()) + return false; return true; }