When I try to use the repeat until block with a variable, the loop isn't broken when the variable evaluates to true. The value is broadcast from the other sprite script and change at the end of the script. After the change I tried to rebroadcast the variable but that didn't work either. What am I not getting?
Offline
Post script. I can't quite understand you.
Offline
I want sprite one to control the action of sprite 2. First the script for sprite 1, then for sprite 2.
when gf clicked
set size to (100) %
go to x: (-160) y: (90)
set [sound_exist] to [0]
repeat (20)
move (7) steps
next costume
move (7) steps
end
if <touching [sprite 3] ?>
go to x: (160) y -90)
set size to (50) %
end
broadcast [sound_exist]
play sound [Pink-Get This] until done
change [sound_exist] by (1)
broadcast [sound_exist]
glide (10) secs to x: (-160) y: (90)
stop script
[/scratchblocks]
when I receive [sound_exist] show variable [sound_exist] switch to costume [jodi1] go to x: (-130) y: (-13) set size to (100) % repeat until <[sound_exist] = [1] switch to costume [jodi2] wait (0.25) secs switch to costume [jodi1] wait (0.25) secs end go to x: (-167) y: (-63) set size to (50) % stop scriptthe problem is the repeat loop never ends. I am under the impression that when the variable evaluates true that the loop is broken. Where am i going wrong? Thank you for your help.
Offline
Must hawhen gf clicked
set size to (100) %
go to x: (-160) y: (90)
set [sound_exist] to [0]
repeat (20)
move (7) steps
next costume
move (7) steps
end
if <touching [sprite 3] ?>
go to x: (160) y: (-90)
set size to (50) %
end
broadcast [sound_exist]
play sound [Pink-Get This] until done
change [sound_exist] by (1)
broadcast [sound_exist]
glide (10) secs to x: (-160) y: (90)
stop script
[/scratchblocks]ve made a typo with the first script: let me try again.
Offline
and again!
when gf clicked set size to (100) % go to x: (-160) y: (90) set [sound_exist] to [0] repeat (20) move (7) steps next costume move (7) steps end if <touching [sprite 3] ?> go to x: (160) y: (-90) set size to (50) % end broadcast [sound_exist] play sound [Pink-Get This] until done change [sound_exist] by (1) broadcast [sound_exist] glide (10) secs to x: (-160) y: (90) stop script
Offline
For the second one, repeat until what?
Offline
when I receive [sound_exist v] show variable [sound_exist v] switch to costume [jodi1 v] go to x: (-130) y: (-13) set size to (100) % repeat until <(sound_exist) = [1]>// Is this right switch to costume [jodi2 v] wait (0.25) secs switch to costume [jodi1 v] wait (0.25) secs end go to x: (-167) y: (-63) set size to (50) % stop scriptAhh Fixed
Last edited by letmethink (2012-12-25 05:48:14)
Offline
How long is the music?
Offline
rickvh wrote:
Closer, but I still don't get the pointy ends...Maybe I need a space between the greater than symbol and the bracket.
< [sound_exist] = [0] >let's see what happens now
Try using normal brackets like this,
<(sound_exist)=[0]>
Which makes
<(sound_exist)=[0]>instead of square brackets like this
< [sound_exist] = [0] >I hope I helped, letmethink
Offline
when gf clicked set size to (100) % go to x: (-160) y: (90) set [sound_exist] to [0] repeat (20) move (7) steps next costume move (7) steps end if <touching [sprite 3] ?> go to x: (160) y: (-90) set size to (50) % end broadcast [sound_exist] play sound [Pink-Get This] until done change [sound_exist] by (1) broadcast [sound_exist] // Is this needed? glide (10) secs to x: (-160) y: (90) stop scriptOh and by the way you can't get pointy ends, it is one of the limitations of the scratchblock bbcode.
Last edited by letmethink (2012-12-25 05:54:03)
Offline
When you write the code out in the forum the operator looks correct when you post, but when I fill in the square white boxes of the = operator in the Scratch program the block has pointy ends and a square white rectangle with the string in it.
Also, I don't know if the second broadcast block is needed. I assumed when the value changed that I had to re-broadcast to effect the change since the script stops after the next block. Once the broadcast block is triggered by the script does it broadcast continuously and reflect changes in value when they occur or does it broadcast just once with the value the variable is at when triggered?
And, I'd be glad to send you the project file. What's the best way to do so? E-mail it to you as an attachment? Or is there some way to post it here besides writing out the scripts for all three sprites? I am going to write out the script for one of the sprites with the offending operator in it to see what it looks like when I post it. If it looks as it should when posted I may have a bug in my Scratch program. If so, it would reflect the story of my life! Thank for your help!
Offline
Let's see what happens!
when I receive [sound_exist v] show variable [sound_exist v] if < (sound_exist) = [0] > go to x: [-130] y: [-13] set size to [100] % forever switch to costume [jodi2 v] wait [0.25] secs switch to costume [jodi1 v] wait [0.25] secs end else stop script end
Offline
This is what it should look like in my scratch program's scripts panel, but doesn't! The green operator has pointy ends and sound_exist is in a white rectangle. Is there any way of checking the bbcode in my Scratch program?
Offline
The operator is meant to have pointy ends,
Are you sure that you made sound_exist a variable?
Offline
I happy I could help, I thought your typed variable looked suspicious.
Offline