Discuss Scratch

Toodchop
Scratcher
100+ posts

"Percentage Between" Operators Block

Note: If you’d like, feel free to reply with what you think the benefits of this block could be, or how you might use it in your projects!

Hello! I have a suggestion for a new operators block that could be really helpful for math-based projects. The idea is a “percentage between” block that calculates the percentage of the distance between two numbers. Here's how it would work:

The block would look like this:

(50) % between (1) and (5) :: operators reporter

For example,

(50) % between (1) and (5) :: operators reporter : // would return 3 (the midpoint).

(25) % between (1) and (5) :: operators reporter : // would return 2 (a quarter of the way).

This block would simplify the process of calculating midpoints and percentages without needing to manually use formulas like:

(((x) + (y)) / (2))

Example use:

when green flag clicked
forever
go to ((50) % between ([x position v] of (red ball v)) and ([x position v] of (blue ball v)) :: operators)
end

It would be a great tool for anyone working with animations, game mechanics, or even math lessons. Let me know what you think!

Last edited by Toodchop (Oct. 9, 2025 09:43:50)

jmdzti_0-0
Scratcher
1000+ posts

"Percentage Between" Operators Block

You don’t need different formulae for each percentage:

Last edited by jmdzti_0-0 (Aug. 8, 2025 10:25:36)

Toodchop
Scratcher
100+ posts

"Percentage Between" Operators Block

jmdzti_0-0 wrote:

You don’t need different formulae for each percentage:
Oh, I didn't know that!
jmdzti_0-0
Scratcher
1000+ posts

"Percentage Between" Operators Block

also: 25% of (1+5) is 1.5, not 2.
aaliyaan0110
Scratcher
500+ posts

"Percentage Between" Operators Block

i think that would be used for gambl games, no support

Last edited by aaliyaan0110 (Aug. 8, 2025 10:54:18)

jmdzti_0-0
Scratcher
1000+ posts

"Percentage Between" Operators Block

aaliyaan0110 wrote:

i think that would be used for gambl games, no support
well, the
(pick random (0) to (10))
block can also be used to make gambling games and it’s still there as far as i know. don’t bring up ridiculous arguments to not support.

anyways, i think gambling games ARE allowed on scratch as long as they don’t involve real money and whatnot (* i am using that word way too much today). you can’t monetize projects on scratch at all

Last edited by jmdzti_0-0 (Aug. 8, 2025 18:01:55)

Toodchop
Scratcher
100+ posts

"Percentage Between" Operators Block

jmdzti_0-0 wrote:

also: 25% of (1+5) is 1.5, not 2.
This block calculates a given percentage of the range between two numbers, not their sum.

Last edited by Toodchop (Aug. 9, 2025 02:01:21)

Toodchop
Scratcher
100+ posts

"Percentage Between" Operators Block

Bump.
Toodchop
Scratcher
100+ posts

"Percentage Between" Operators Block

aaliyaan0110 wrote:

i think that would be used for gambl games, no support
This block calculates a given percentage of the range between two numbers, not calculate a chance.
Quantum-Cat
Scratcher
1000+ posts

"Percentage Between" Operators Block

In programming, this operation is usually called lerp (linear interpolation), and the formula is a + (b-a) * percentage/100 (or instead of percentage/100, a parameter t that goes between 0 and 1.0). I think it was suggested a few times before, but I honestly think your phrasing of the block is more beginner-friendly.
jmdzti_0-0
Scratcher
1000+ posts

"Percentage Between" Operators Block

ignore this post

Last edited by jmdzti_0-0 (Sept. 6, 2025 21:54:08)

medians
Scratcher
1000+ posts

"Percentage Between" Operators Block

jmdzti_0-0 wrote:

Quantum-Cat wrote:

In programming, this operation is usually called lerp (linear interpolation), and the formula is a + (b-a) * percentage/100 (or instead of percentage/100, a parameter t that goes between 0 and 1.0). I think it was suggested a few times before, but I honestly think your phrasing of the block is more beginner-friendly.
a + (b-a) is just b
With the formula given in that post, you cannot do that. You have to follow order of operations
ispretty
Scratcher
500+ posts

"Percentage Between" Operators Block

jmdzti_0-0 wrote:

Quantum-Cat wrote:

In programming, this operation is usually called lerp (linear interpolation), and the formula is a + (b-a) * percentage/100 (or instead of percentage/100, a parameter t that goes between 0 and 1.0). I think it was suggested a few times before, but I honestly think your phrasing of the block is more beginner-friendly.
a + (b-a) is just b
you're not accounting for the order of operations, it's a + ((b-a) * percentage/100) (which you can't simplify further)
Toodchop
Scratcher
100+ posts

"Percentage Between" Operators Block

Bump.
aaliyaan0110
Scratcher
500+ posts

"Percentage Between" Operators Block

how is everybody good at math
Toodchop
Scratcher
100+ posts

"Percentage Between" Operators Block

aaliyaan0110 wrote:

how is everybody good at math
I hope the block is NOT too complex for Scratch.
Toodchop
Scratcher
100+ posts

"Percentage Between" Operators Block

Bump.
Toodchop
Scratcher
100+ posts

"Percentage Between" Operators Block

Toodchop wrote:

Bump.
Bump.
Toodchop
Scratcher
100+ posts

"Percentage Between" Operators Block

Toodchop wrote:

Toodchop wrote:

Bump.
Bump.
Bump.
Za-Chary
Scratcher
1000+ posts

"Percentage Between" Operators Block

Just curious, what are some practical uses for this block? In particular, you mention animations and game mechanics, but what specifically can this block be used for in those instances?

Powered by DjangoBB