Intergers only

id: 750480

category: Help with Scripts

posts: 5

I need my variables to only allow inters to be what it is, not to not allow decimals but to round it to the nearest whole number
After setting your variable to a number, you could round it with the round block.
Vaibhs11 Vaibhs11 loading
There are three blocks that you could use:

(round (...)) // rounds to nearest integer: 1.75 => 2 // 1.25 => 1
([floor v] of (...)) // rounds to nearest integer below the number: 1.75 => 1 // 1.25 => 1
([ceiling v] of (...)) // rounds to the nearest integer above the number: 1.75 => 2 // 1.25 => 2

You could also use the floor function just to remove the decimal part of a number.
(this post just combines the ones above by Vaibhs11 and legendary34678)
Every time you update the variable, you could do
set [var v] to (round (var))

alternatively whenever adding to the variable just include a round block
change [var v] by (round (equation here))

Vaibhs11 wrote:

There are three blocks that you could use:

(round (...)) // rounds to nearest integer: 1.75 => 2 // 1.25 => 1
([floor v] of (...)) // rounds to nearest integer below the number: 1.75 => 1 // 1.25 => 1
([ceiling v] of (...)) // rounds to the nearest integer above the number: 1.75 => 2 // 1.25 => 2

You could also use the floor function just to remove the decimal part of a number.
thank you that worked