Discuss Scratch

IAMTHEOWL
Scratcher
38 posts

How to stop a broadcast block in a forever loop.

I'm making a game that has the code:
when I receive [say  v]
forever
if <[(says)] = [Hello]> then
broadcast [Hi v]



else
if <[(says)] = [Hi]> then
broadcast [Hello v]



else

end

end
etc
But the broadcast block is in a forever loop so it keeps on running the code:
when I receive [ Hi v]
say (join [Hello,] [(name)]) for (2) secs

so dose any body know how to make the
forever
if <[(says)]> = [Hello]> then
broadcast [Hi v]
end

part not broadcast it forever?

Last edited by IAMTHEOWL (June 3, 2020 20:19:29)

deck26
Scratcher
1000+ posts

How to stop a broadcast block in a forever loop.

So why is it a forever loop if you don't want that to happen. If you only want it to happen once each time the event occurs add a wait until not event.
ninjaMAR
Scratcher
1000+ posts

How to stop a broadcast block in a forever loop.

when I receive [say v]
if <code here> then
broadcast [hi v]
end
IAMTHEOWL
Scratcher
38 posts

How to stop a broadcast block in a forever loop.

deck26 wrote:

So why is it a forever loop if you don't want that to happen. If you only want it to happen once each time the event occurs add a wait until not event.

because It's a
if <> then

end
block so it has to be in a forever loop.
IAMTHEOWL
Scratcher
38 posts

How to stop a broadcast block in a forever loop.

ninjaMAR wrote:

when I receive [say v]
if <code here> then
broadcast [hi v]
end

I need it to be an
if <> then 



else

end
or it wont work I already tried.
TheSassyDiamond
Scratcher
100+ posts

How to stop a broadcast block in a forever loop.

stop [all v]
IAMTHEOWL
Scratcher
38 posts

How to stop a broadcast block in a forever loop.

TheSassyDiamond wrote:

stop [all v]

it kinda works but not really. I need something else.
theanonymousweirdo
Scratcher
500+ posts

How to stop a broadcast block in a forever loop.

when I receive [say  v]
wait until<<(says) = [Hello]> or <(says) = [Hi]>>
if <(says) = [Hello]> then
broadcast [Hi v]
else
if <(says) = [Hi]> then
broadcast [Hello v]
else
end
end

Last edited by theanonymousweirdo (June 3, 2020 22:45:57)

Wyan100
Scratcher
1000+ posts

How to stop a broadcast block in a forever loop.

Did you try a

wait until <Event>

Block?
deck26
Scratcher
1000+ posts

How to stop a broadcast block in a forever loop.

I prefer to use wait until in those circumstances rather than an if block wihin a forever loop. However you can still do it that way - just stop the script after the broadcast.
RainbowsToybox
Scratcher
100+ posts

How to stop a broadcast block in a forever loop.

Use the repeat block. You control how long it loops for,. You'll need to experiment a lot to get it to stop at the right point.

Block (Just in case):
repeat ()

end

Located under the forever block.

Powered by DjangoBB