i think a lot of other scratch users are wishing for this, so here it is. it would be nice for the next version of scratch to feature a command block stating "wait until I recieve [signal]". such a block would let us create scripts that pause until a trigger is set.
Offline
Right now you can use a variable for this:
[blocks]<set{ VAR }to( 1
<repeat until><( <{ VAR }> <=> 0 )>
[stuff]
<end>[/blocks]
Offline
AmoebaMan wrote:
I think a lot of other scratch users are wishing for this, so here it is: It would be nice for the next version of scratch to feature a command block stating "wait until I receive [signal]". such a block would let us create scripts that pause until a trigger is set.
I agree. It can be very tedious, making so many variables. It would also be helpful to have a
[blocks] <{ broadcast }>[/blocks] block, so you can make something like "Wait until a is broadcast":
[blocks]<wait until> <( a <=><{ broadcast }> )> [/blocks]
Or, you can have:
[blocks] <forever if><( a <=><{ broadcast }> )>
<repeat until><( b <=><{ broadcast }> )>
<move( 10 )steps>
<end>
<end>[/blocks]
Last edited by hpotter134 (2010-03-18 11:30:30)
Offline
I don't know how many times I've had to type this, but it WON"T HAPPEN BECAUSE BROADCASTS AREN'T BOOLEAN.
Boolean means the answer is 0 or 1. All of the diamond-shaped blocks are boolean, <a = 1> is boolean because either a is equal to one or a is not equal to one, 1 being if it is equal and 0 being if it isn't.
Offline
There is an easy way to do this:
[blocks] <wait until><( <{ var }> <=> 1 )> [/blocks]
That's the way I would do it, any way.
Offline
coolstuff wrote:
climber59 wrote:
Then make a boolean that says '..... broadcasting?'
But broadcasts are instantaneous.
coolstuff wrote:
I don't know how many times I've had to type this, but it WON"T HAPPEN BECAUSE BROADCASTS AREN'T BOOLEAN.
Sorry. I didn't think about this enough.
But would it be possible to have a "message" reporter block? That way we could have a
script that says:
[blocks]<wait until><(<{ message }> <=> "a message")>[/blocks]
and the "message" block, like "answer", stays the same until another message is broadcast. Is this possible? Please explain, for I really don't know much about this. I just started learning Smalltalk and have a long way to go.
Offline
hpotter134 wrote:
coolstuff wrote:
climber59 wrote:
Then make a boolean that says '..... broadcasting?'
But broadcasts are instantaneous.
coolstuff wrote:
I don't know how many times I've had to type this, but it WON"T HAPPEN BECAUSE BROADCASTS AREN'T BOOLEAN.
Sorry. I didn't think about this enough.
But would it be possible to have a "message" reporter block? That way we could have a
script that says:
[blocks]<wait until><(<{ message }> <=> "a message")>[/blocks]
and the "message" block, like "answer", stays the same until another message is broadcast. Is this possible? Please explain, for I really don't know much about this. I just started learning Smalltalk and have a long way to go.
Ah... Please excuse my answer from way back then - I was rather rude, wasn't I?
Regardless, I think it could happen: While an "I receive" message isn't boolean because broadcasts are instantaneous, "I have received" or "I am receiving" message will do just fine.
Offline
hpotter134 wrote:
Sorry. I didn't think about this enough.
But would it be possible to have a "message" reporter block? That way we could have a
script that says:
[blocks]<wait until><(<{ message }> <=> "a message")>[/blocks]
and the "message" block, like "answer", stays the same until another message is broadcast. Is this possible? Please explain, for I really don't know much about this. I just started learning Smalltalk and have a long way to go.
Broadcasts don't really exist in any Smalltalk images, except for Scratch. They implimented this just fo it.
Offline
hpotter134 wrote:
coolstuff wrote:
climber59 wrote:
Then make a boolean that says '..... broadcasting?'
But broadcasts are instantaneous.
coolstuff wrote:
I don't know how many times I've had to type this, but it WON"T HAPPEN BECAUSE BROADCASTS AREN'T BOOLEAN.
Sorry. I didn't think about this enough.
But would it be possible to have a "message" reporter block? That way we could have a
script that says:
[blocks]<wait until><(<{ message }> <=> "a message")>[/blocks]
and the "message" block, like "answer", stays the same until another message is broadcast. Is this possible? Please explain, for I really don't know much about this. I just started learning Smalltalk and have a long way to go.
I don't see why not. The only problem I see with this is that such a thing can be pretty easily implemented with variables.
Last edited by Harakou (2010-09-10 20:37:02)
Offline
This topic is rather old, so I doubt anyone cares, but I succeeded in finally making myself a "message" block that does what I suggested. It uses class variables, and accessing methods and stuff. I posted it here in the Advanced Topics section.
Then, instead of
I can do
Last edited by hpotter134 (2011-01-25 20:34:50)
Offline