I am curious if there is a way to find out what sequence of order various commands get "attention" when a program is running?
It appears that you have to add a "forever" loop to get some commands to be checked more often, instead of when the "cycle" next gets around to them. For example, watching for certain key presses.
But the main problem with "forever" loops is that they cannot be used with broadcast messages (when received). So those broadcast messages don't always get attention in a timely manor.
I am also curious if having multiple groups of commands for a sprite, causes them to be operated in a certain sequence?
Offline
The "commands" or blocks, run in the order you put them in the scratch program.
About the forever and broadcast problem, you could use variables instead of broadcasts like this:
[forever]
[if <(variable) = 1)]
[switch to costume (costume1)]
[else]
[wait until <variable=1>]
[end if else]
[end forever]
You would set the variable to 1 (or what ever else you like) instead of broadcasting a message
If you would like to see what blocks are doing what at what time, click "Edit", "Set Single Stepping", and click either fast or slow flash blocks. It will highlight your blocks as they are running so you know which blocks are working.
Offline
Yes I know that the "blocks" run in the order of their placement in the scripts, but what I was wondering is when you have multiple "scripts" for a single sprite, then what order does Scratch allocate to running them
For example when using [Broadcast] blocks in one script and [When receive broadcast] blocks in another. Or say when you have a "loop" that looks for a certain key press, and then does something. This is whats got me curious about the sequence that Scratch allocates to each grouping. Most have a certain thing that needs to happen before the other script can start-up and do something else, but there appears to be some "large" delays between when some things are happening.
Also, I see many recommend that you put key press scripts inside [Forever loops] so to reduce the delays between when you actually press the key and when the script reacts. This difference of having the [Forever loop] and not is whats got me curious. And also some blocks cannot be used inside the [Forever loops], such as the [When I recieve] or [When -- key pressed] blocks (all "Hat" blocks).
I have been working on a program, which I have recoded the search to make it more efficient, and use broadcast blocks when the correct item is found, which causes the search to stop and go to the next thing to do, and then the program loops back to the next items in the list and starts the search from the beginning again. But this coding is so very much slower than to have Scratch just do a "brute force" search through all the items it is comparing each thing to, no matter if the found items is the first thing in the list (it still has to go through the whole list).
Now, with most other languages you can use loops and subroutines to "economize" your coding, but in Scratch I can only see [Broadcast] blocks as a way to jump to other "subroutines", and then back to the beginning of the search list.
Hopefully this better explains my question???
Thanks again for your input.
Offline