Discuss Scratch

Roblox888i
Scratcher
1000+ posts

New operator!

(round (89) to the nearest (10)::operators) // would result in a 90 because 5 or high give it a shove or 4 below go to the ground.

Not gonna replace the current round block

Last edited by Roblox888i (April 15, 2022 05:15:29)

MarkGamez
Scratcher
31 posts

New operator!

yes

Last edited by MarkGamez (April 12, 2022 20:29:57)

SomeoneOnThelnternet
Scratcher
1000+ posts

New operator!

MarkGamez wrote:

yes
Please be constructive and explain why you agree.
Conduit7
Scratcher
100+ posts

New operator!

yeah cuz then you could do a
(round (timer::variables) in the [tenths v] place::operators)
i know this would be very helpful for people creating games 'cause then making a timer could be smthn like this:
define setTime
set [TIME v] to (join (join (minutes) [']) (round (%time) in the [tenths v] place::operators))
this could be very useful in my games when i want a timer cuz what i could do is
when green flag clicked
set [frame v] to (0)
forever
change [frame v] by (1)
set [%timer v] to ((frame)/(30))
setTime
end
to get an exact time

Last edited by Conduit7 (April 15, 2022 22:36:44)

OPagel
Scratcher
500+ posts

New operator!

Support! I can see how this could be helpful, though I wonder if the options would appear depending on the amount of digits.
Steve0Greatness
Scratcher
1000+ posts

New operator!

There is technically a workaround. The script below is from @Scratch-Minion in Round to nearest (num)?(Help with Scripts).
(round ((#) / (Place Value))) * (Place Value)
This isn't saying that this isn't useful, it's just so that you can have the same functionality encase the ST doesn't introduce this feature into Scratch.

Last edited by Steve0Greatness (April 13, 2022 00:38:25)

k0d3rrr
Scratcher
1000+ posts

New operator!

Just being honest, but the mock-up had a flaw:
round [23,789] in the [tens v] place:: operators reporter // There should be an integer, not a string.
Here's what the actual block should look like:
round (23789) in the [tens v] place:: operators reporter // As you can see, it now has an integer instead of a string.
// Side note: The block above has no comma because it would register as a variable instead of an integer.
Edit: Also, I probably found a duplicate: https://scratch.mit.edu/discuss/topic/356544/

Last edited by k0d3rrr (April 13, 2022 01:42:31)

k0d3rrr
Scratcher
1000+ posts

New operator!

Bump?
Icefan13
Scratcher
100+ posts

New operator!

workaround:
((round((...::grey)/(10)))*(10))
replace the 10 with the place you want to round to. The ST tends not to add blocks with easy workarounds

Last edited by Icefan13 (April 14, 2022 15:40:35)

Conduit7
Scratcher
100+ posts

New operator!

yes even though there is an easy workaround, this could simplify code for some beginners. just like you could replace the
glide block with this:
set [ending x v] to ()
set [ending y v] to ()
set [time v] to ()

set [sx v] to (((ending x)-(x position))/(time))
set [sy v] to (((ending y)-(y position))/(time))
repeat until <<(round (x position))=(ending x)>and<(round (y position))=(y)>>
change x by (sx)
change y by (sy)
end
go to x (ending x) y (ending y)
there is a workaround for a LOT of blocks out there, and this could just simplify it from this:
((round((var)*([10^ v] of [places away from decimal]::operators)))/([10^ v] of [places away from decimal]::operators):: operators report //place values below 1
((round((var)/([10^ v] of [places away from decimal]::operators)))*([10^ v] of [places away from decimal]::operators):: operators report //place values above .1
to this:
(round (var) to the [tenths v] place::operators)
you'll have a hard time convincing me that this isn't a much easier thing to understand

Last edited by Conduit7 (April 15, 2022 23:50:35)

SpinningCube
Scratcher
100+ posts

New operator!

Here's a more flexible design:

(round () to the nearest ()::operators)

which would basically be defined as:

define (round (A::custom) to the nearest (B::custom)::operators)
report ((round((A::custom) / (B::custom))) * (B::custom))::custom

so for example:

(round (4) to the nearest (10)::operators)//reports 0
(round (7) to the nearest (10)::operators)//reports 10
(round (15) to the nearest (10)::operators)//reports 20
(round (4) to the nearest (7)::operators)//reports 7
(round (23) to the nearest (7)::operators)//reports 21
(round (14) to the nearest (3.1415926536)::operators)//reports 12.5663706144

Very useful but also pretty workaroundable
Roblox888i
Scratcher
1000+ posts

New operator!

SpinningCube wrote:

Here's a more flexible design:

(round () to the nearest ()::operators)

which would basically be defined as:

define (round (A::custom) to the nearest (B::custom)::operators)
report ((round((A::custom) / (B::custom))) * (B::custom))::custom

so for example:

(round (4) to the nearest (10)::operators)//reports 0
(round (7) to the nearest (10)::operators)//reports 10
(round (15) to the nearest (10)::operators)//reports 20
(round (4) to the nearest (7)::operators)//reports 7
(round (23) to the nearest (7)::operators)//reports 21
(round (14) to the nearest (3.1415926536)::operators)//reports 12.5663706144

Very useful but also pretty workaroundable
fixed op!
historical_supa
Scratcher
1000+ posts

New operator!

This is a dupe: https://scratch.mit.edu/discuss/topic/76238/

Last edited by historical_supa (April 16, 2022 00:13:18)

k0d3rrr
Scratcher
1000+ posts

New operator!

historical_supa wrote:

This is a dupe: https://scratch.mit.edu/projects/493918300/
Ah ha! You tricked me!
Conduit7
Scratcher
100+ posts

New operator!

i would say support this would be a very helpful block

Last edited by Conduit7 (April 15, 2022 23:51:09)

historical_supa
Scratcher
1000+ posts

New operator!

k0d3rrr wrote:

historical_supa wrote:

This is a dupe: https://scratch.mit.edu/projects/493918300/
Ah ha! You tricked me!
wait why is this that link bruh
historical_supa
Scratcher
1000+ posts

New operator!

Roblox888i
Scratcher
1000+ posts

New operator!

This topic is still open tho
DarthVader4Life
Scratcher
1000+ posts

New operator!

Roblox888i wrote:

This topic is still open tho
That's… not really how duplicates work.
If a newer topic suggests the same thing as an older one, then the newer is generally closed in favor of the older.
They aren't necessarily closed immediately.
cosmosaura
Scratch Team
1000+ posts

New operator!

It looks like this is a duplicate topic of this one over here https://scratch.mit.edu/discuss/topic/76238/ so I'll close it to keep the conversation all in one place.

Please use the existing topic in the link above.

Powered by DjangoBB