Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » position comparison
- jbhcoder
-
3 posts
position comparison
Till yesterday, I was able to check position with
<(x position) = [40]>or any integer, and it worked. But now it is suddenly stopped working. I now have to perform
<([ceiling v] of ((x position))) = [40]>Has this behavior just changed?
- Thingied
-
1000+ posts
position comparison
Check if it has some decimals at the end by clicking the x position reporter.
- jbhcoder
-
3 posts
position comparison
Yes, it has. That's why I have to now use the ceiling function. But I did not have to do that earlier. Is there a way to make it not have those decimal places?
- MasterofTheBrick
-
1000+ posts
position comparison
You can round off decimals to whole numbers using the round () operator.
(round ())
- Thingied
-
1000+ posts
position comparison
Is there a way to make it not have those decimal places?
set x to (0) // Reset the position to a whole number so it won't have any decimals
Last edited by Thingied (Aug. 23, 2021 14:29:20)
- jbhcoder
-
3 posts
position comparison
Already doing that, but I am also doing aIs there a way to make it not have those decimal places?set x to (0) // Reset the position to a whole number so it won't have any decimals
move (15) stepsafter which it always adds the decimal places
- Thingied
-
1000+ posts
position comparison
The round off the coordinates after.Already doing that, but I am also doing aIs there a way to make it not have those decimal places?set x to (0) // Reset the position to a whole number so it won't have any decimalsmove (15) stepsafter which it always adds the decimal places
move (15) stepsIf this gets too tedious, make a custom block to do it instead.
go to x:(round(x position))y:(round(y position))
move (15) steps :: custom
define move (steps) steps
move (steps) steps
go to x:(round(x position))y:(round(y position))
Last edited by Thingied (Aug. 23, 2021 15:38:40)
- Discussion Forums
- » Help with Scripts
-
» position comparison