Div and Int?

Bluevoss
Need to half a value but don't want fractions. So how can I make this command...

squiffy.set("num",squiffy.get("num")/2);

...return whole numbers (rounded down, I suppose).

Dennis Carlyle
You can use Math.round(x) for the nearest whole number, or round down with Math.floor(x).
--------------------------------
@set health = 91

var H = squiffy.get("health")/2;
squiffy.set("health", Math.round(H));

Your Health is now at {health}.

------------------------------------------

Bluevoss
That's what I needed. Many thanks!

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums