You have to do it seperately from all other scripts with a character meaning you have to start a chain of new blocks. I would like to stop certain scripts when I receive certail items. I can't do this, so certain parts of the game don't work out how they should. Example
When left arrow key pressed
switch to costume g2
move -50 steps
Now, you can't add a when i receive to that chain to stop the script. You can't stop the script at all in this case for what i want to do. Here's the example of what i'm looking for
When left arrow key pressed
switch to costume g2
move -50 steps
When I receive stopmotions
stop script
Offline
I think the way around this is:
Firstly, set up a variable "Stopmoving", set to zero.
In place of your "broadcast stopmotions" command, have a "set stopmotions to 1" command.
Then, split your move into several smaller steps, say of -5. Put this inside a "Repeat 10" block.
When left arrow key pressed
switch to costume g2
Repeat 10
if stopmotions = 1
stop
Else
move -5 steps
Offline
I think there should be a 'I receive' button in 'Sensing' for problems like this because I think it is kind of annoying when you have to use a variable just for that.
Offline
Graham, it gets a bit complicated if you want to interrupt a running script.
There are several possible notions for detecting messages that were broadcast:
1) start new scripts, restarting an already running script if necessary. This is what scratch currently does.
2)start new scripts, but *don't* restart already running scripts.
3)raise a flag that the message has been sent, and lower the flag again when a script has received the message. This could be useful for sending single messages to make sure that only one script gets the message (the opposite of the current broadcast scheme). When properly implemented, such semaphores can allow mutual exclusion of critical regions of codes, to make sure that parallel threads don't step on each other.
There is some real difficulty with generalizing this concept to a broadcast though, which seems to be what your suggestion entails.
4) Have explicit "wait for message" blocks that stop a script until a message is received.
This is quite powerful, as it can trivially implement the interactions described in (2) above:
forever
wait for message
do body
Only those scripts that are actually waiting for messages would receive them.
(Of course, the "when I receive" block could continue to have their current semantics of always being ready for a message.)
Offline