Page 1 of 1

Decimals in Lua?

Posted: Sun Sep 04, 2005 7:19 am
by rylleman
I'm trying to write my first script in Lua, going well except for one little thing.

To see if a value is changed I use ~= between the old and the new value. Problem is that Moho round off the value so the condition gets false when it shouldn't be, is there a way to compare two values only down to the first 3 decimals with the expression ~=?

Posted: Sun Sep 04, 2005 8:32 am
by rylleman
Never mind, I figured it out.

if string.format("%.4f", newVal.x) ~= string.format("%.4f", oldVal.x) then