scratchfoundation / scratch-flash

Open source version of the Scratch 2.0 project editor. This is the basis for the online and offline versions of Scratch found on the website.
https://scratch.mit.edu
GNU General Public License v2.0
1.33k stars 513 forks source link

[Suggestion] 'wait' inside non-refresh script temporarily reverts to allowing refresh – i.e. yields – returning to non-refresh once wait ends #1356

Closed TheLogFather closed 5 years ago

TheLogFather commented 7 years ago

This is a fairly common issue to run into for less experienced Scratchers – e.g. using 'broadcast and wait' inside a non-refresh script – and it's easy for even more experienced Scratchers to forget and fall into it. (As seen in https://github.com/LLK/scratch-flash/issues/1339.)

Of course, it's largely through misunderstanding exactly what 'non-refresh' means (i.e. that it's really 'atomic'), but that doesn't seem obvious from the term 'non-refresh'.

A list of blocks that could temporarily switch on yield within non-refresh:   • broadcast and wait   • switch backdrop and wait   • ask and wait   • wait until...   • wait N secs   • glide...   • play sound until done   • play note/drum for N beats

AFAICS, on encountering such a block, a non-refresh thread could simply nullify warpThread (i.e. just call clearWarpBlock?), and set a new Thread public var ("wasWarp"?) that tells the interpreter it needs switching back into 'warp speed' when the wait has ended (i.e. when the next block is not a wait block). Is that all that's needed, or am I missing something?