Intergers only
id: 750480
category: Help with Scripts
posts: 5
person78745476
loading
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
legendary34678
loading
After setting your variable to a number, you could round it with the round block.
Vaibhs11
loading
There are three blocks that you could use:
You could also use the floor function just to remove the decimal part of a number.
(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.
MrKingofScratch
loading
(this post just combines the ones above by Vaibhs11 and legendary34678)
Every time you update the variable, you could do
alternatively whenever adding to the variable just include a round block
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))
person78745476
loading
thank you that worked 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.