Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Why does this happen when a message is broadcasted forever? (wait until block couldn't be ran)
- Eason_9
-
Scratcher
1000+ posts
Why does this happen when a message is broadcasted forever? (wait until block couldn't be ran)
when green flag clicked
forever
broadcast (process v) // This message is supposed to broadcast every single frame.
end
when I receive [broadcast v]
if <mouse down> then // If the mouse button is clicked, 10 is added to the sprite's x value. But for some reason, the change x by 10 block is ignored.
wait until <not<mouse down>>
change x by (10)
end
Why does this happen? I think it's because the process message is broadcasted every single frame which resets the message and doesn't continue it.
I found a workaround by creating a new message for the “wait until not mouse down” and “change x by 10” blocks, so that it can continue there.
But is there a more in-depth explanation of why this happens? Why wouldn't the script just continue when another instance of it is broacasted?
Play with it yourself and you'll know what I mean
Last edited by Eason_9 (Jan. 21, 2025 03:01:02)
- awesome-llama
-
Scratcher
1000+ posts
Why does this happen when a message is broadcasted forever? (wait until block couldn't be ran)
I think it's because the process message is broadcasted every single frame which resets the message and doesn't continue it.
Correct. That's just the way it is designed. I don't know how that decision was reached.
https://github.com/scratchfoundation/scratch-vm/blob/develop/src/blocks/scratch3_event.js#L60
event_whenbroadcastreceived: { restartExistingThreads: true }
- Discussion Forums
- » Help with Scripts
-
» Why does this happen when a message is broadcasted forever? (wait until block couldn't be ran)