a % b == a - math.floor(a/b)*b
-5.1 % 1 -----> -0.1 in JS (-1..1)
-5.1 % 1 -----> 0.9 in Lua (0..1)
function round_or_nil(num)
local diff = num % 1
if diff <= 0.1 or diff >= 0.9 then
return math.floor(num + 0.5)
end
return nil
end