This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-04-08 15:39:17

kungpowch1ken
New Scratcher
Registered: 2012-04-08
Posts: 6

how to send a momentary broadcast

Is it possible to send out a broadcast once and then stop it?

Offline

 

#2 2012-04-08 15:54:35

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

Re: how to send a momentary broadcast

Yes... Use this...

when gf clicked
do stuff
broadcast [message]
wait [how many numbers of secs you want] secs
stop script


Get ready for domination of:  tongue

Offline

 

#3 2012-04-08 15:59:14

Splodgey
Scratcher
Registered: 2011-04-26
Posts: 500+

Re: how to send a momentary broadcast

If you meant to stop the broadcasted script, then no, unless you put the "stop script" in the broadasted script.

Offline

 

#4 2012-04-08 16:18:48

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: how to send a momentary broadcast

If Splodgey is correct in what you want to know:

You'd have to use the broadcast script to check a variable.  Something like this:

set [stop? v] to [false]
broadcast [event v]
wait (5) secs
set [stop? v] to [true]
When I Receive [event v]
do stuff
if<(stop?) = [true]>
stop script
end
do stuff
if<(stop?) = [true]>
stop script
end
etc.
or, if it is a loop:

When I Receive [event v]
repeat until <(stop?) = [true]>
do stuff
end
Edit: the more frequently you check if "stop?" is true, the faster it will stop.  For instance, script #3 will stop after completing the script it is going through and simply not repeat again.  If there is a lot of stuff in the loop, you might want to consider building in some if statements in the loop itself (combining the two methods)

Last edited by MoreGamesNow (2012-04-08 16:22:31)


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#5 2012-04-08 16:57:30

SOScratch
Scratcher
Registered: 2010-02-01
Posts: 100+

Re: how to send a momentary broadcast

Just stick in a

stop script
at the end of the broadcast!

(YAY! My 100th post on the forums!)

Last edited by SOScratch (2012-04-08 16:57:56)


-SOScratch
Scratch On!

Offline

 

#6 2012-04-09 08:19:06

kungpowch1ken
New Scratcher
Registered: 2012-04-08
Posts: 6

Re: how to send a momentary broadcast

the reason I thought I should use a broadcast is because I'm using a sprite as a 'lives bar', and I didn't want to use it as a variable. is there any other, possibly easier, way to do that?

Offline

 

#7 2012-04-09 09:13:03

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: how to send a momentary broadcast

I'm pretty sure you'd have to use a variable, though you could work around it using the "[x position] of [sprite 1]", and tying it to another sprite's costume, x position, etc., but the result would still be variable-esque.  Why don't you want to use a variable?

Edit:

something like this:

when gf clicked
forever
if<(health) > [90]>
switch to costume [90-100 v]
else
if<(health) > [80]>
switch to costume [80-90 v]
else
etc.
end
end

Last edited by MoreGamesNow (2012-04-09 09:15:20)


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#8 2012-04-09 10:28:01

kungpowch1ken
New Scratcher
Registered: 2012-04-08
Posts: 6

Re: how to send a momentary broadcast

it's a mario game and I just think that a variable showing the number of lives would just look ugly

Offline

 

#9 2012-04-09 10:50:50

ftf841
Scratcher
Registered: 2012-02-19
Posts: 1000+

Re: how to send a momentary broadcast

kungpowch1ken wrote:

it's a mario game and I just think that a variable showing the number of lives would just look ugly

you can hide variables


http://mag.racked.eu/cimage/i9002/Achievement++get%21/Hi+there./mca.png
http://mag.racked.eu/mcimage/i354/Achievement++get%21/CAKE%21%21%21%21%21/mca.png

Offline

 

#10 2012-04-09 13:46:15

Splodgey
Scratcher
Registered: 2011-04-26
Posts: 500+

Re: how to send a momentary broadcast

MoreGamesNow wrote:

I'm pretty sure you'd have to use a variable, though you could work around it using the "[x position] of [sprite 1]", and tying it to another sprite's costume, x position, etc., but the result would still be variable-esque.  Why don't you want to use a variable?

Edit:

something like this:

when gf clicked
forever
if<(health) > [90]>
switch to costume [90-100 v]
else
if<(health) > [80]>
switch to costume [80-90 v]
else
etc.
end
end

Doesn't anyone get using costume numbers?

when gf clicked
forever
switch to costume (round ((health) / [10]))
Simple.

Offline

 

#11 2012-04-09 13:54:51

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: how to send a momentary broadcast

If you want accuracy though, it's probably easiest to use pen (assuming you're not using pen elsewhere in the project).

@Splodgey - oops.  Forgot about the round block x(  Thanks for the correction  smile

Last edited by MoreGamesNow (2012-04-09 13:56:46)


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

Board footer