Discuss Scratch

darkness3560
Scratcher
100+ posts

Boolean input execution order incorrect

I've been programming a brick-breaker program and made a bounce block for the ball. The block is “if <boolean1>, bounce”. Inside is a script that makes the ball bounce (inside an “if <boolean1>” C-block), and underneath is a “repeat until <not <boolean1>>, move 10 steps” block. However, the “repeat until” block never stops, and I found it to be a Scratch bug in this project. Take a look at that project to see what I found. Thanks, darkness3560.
My browser / operating system: Ubuntu Linux 13.04, Chrome 30.0.1599.114, Flash 11.2 (release 202, NOT Pepper Flash)
DadOfMrLog
Scratcher
1000+ posts

Boolean input execution order incorrect

It's not a bug, but rather you're misunderstanding what it means to give a parameter to a custom block.

You're not giving it the statement “test=0”, but rather you're passing the value of “test=0” at the point when the custom block begins. Changing the value of test once inside the block has no effect on the value of boolean1, because it was fixed before you made the change.

Think of it as if you're sending a ‘snapshot’ of the value of the boolean statement “test=0” right at the point the custom block begins.

For example, the following will never end:
when GF clicked
set [number v] to [0]
get stuck (number) // sends fixed value of zero to the custom block
define get stuck (value)
repeat until <(value) > (0)> // never happens because "value" never changes...
change [number v] by (1)// ...even though variable "number" does
end

Hope that makes sense!

Last edited by DadOfMrLog (Jan. 28, 2017 12:10:12)



Alternate account: TheLogFather –– HowTos and useful custom blocks (see studio). Examples below…


- String manipulation - - - X to power of Y - - - Clone point to clone - Detect New Scratcher - Speed tests studio -

Powered by DjangoBB

Standard | Mobile