You should not compare floating point numbers like this. It is best to compare them with an epsilon value as such:
local epsilon = 0.0000001
function compareFloats(a, b)
if math.abs(a - b) < epsilon then
return true
end
return false
end
I have not tested this code. Good luck!
http://lua-users.org/wiki/FloatingPoint