When I broadcast a variable name does the value broadcast with it? I am assuming so but my script doesn't doesn't behave like it. I initially created a variable called sound exist then set sound exist = 0 in the script of one sprite. Then when sprite one does it's thing I broadcast sound exist. Then play sound until done and then change sound exist by one.
In sprite two I created an if else statement: if: sound exist = 0 a forever loop is started, else: sprite two goes to a location and stays there. The problem is: even though the script for sprite one set the variable to 0 It doesn't seem to be evaluated by the if-else statement in sprite two and it bypasses the whole block.
Also, is the broadcast continuous or must you rebroadcast every time a value changes?
Offline
All right, your wording's a little confusing but I think I get what you're saying. When you broadcast a variable by taking the variable name from the variable block list, the round orange block with the name on it, and placing it on the dropdown list and snapping it into that space, it broadcasts the value of the variable. For instance, the script
broadcast [sound exist]will broadcast the value of the variable at the time the script is executed. What is the hat block of the script that tells the sprite to see if "sound exist" equals zero. You know, is it, when green flag clicked, when I recieve..., or something like that?
Offline
I would try:
when flag clicked forever if <(sound exist)=(0)> broadcast [play v] else broadcast [stop v] end endThen on another sprite:
when I receive [play v] Play sound [music v] until done
when I receive [stop v] forever stop all sounds end
Last edited by mmww (2012-12-23 11:36:09)
Offline
mmww's script should work. Try that and let us know if you have any more problems.
Offline
The thing is: I am trying to control the actions of another sprite not the sound . However, I think I can apply this strategy to that end. Thanks! Also, I didn't know you could have multiple scripts for the same sprite... I'm learning!
Offline
When I try to use statements that require operators such as if, if-else, repeat until and wait until the operator doesn't seem to get evaluated. I set the value of a variable in the script of another sprite and broadcast the variable name. Does the value not get broadcast as well? Or am I using the operators incorrectly? I use a string on one side and an integer on the other:
<(sound_exist) = [0]>The if statement works with the sensing function 'touching' though.
Offline
My operator doesn't look like the one in my last post either! It has pointy ends and the string is on a white background like the integer. do I need to put the variable name in parenthesis when I fill in the little white boxes of the = operator? what am I not getting?
Offline
In going through the help topics I answered my own question concerning the Stop All controller. But there is nothing I can do to get the if-else statement to evaluate my "sound_exist=0" operator. I even tried to set sound_exist to 0 immediately before the if-else block and it still went right through to the else section. ???
Offline