I think that it would be extremely useful, with potentially a very large number of these uses, to have a sort of way to attach a variable to a broadcast.
Additionally, to broadcast to a specific sprite.
so, for instance, you could have a block that says:
{ Broadcast |message| to |Sprite1| }
{ Broadcast |message| to |All| }
{ Broadcast |message| to |Stage| }
and for attaching a value, I'm not sure what the most user-friendly way to do it would be, but something like:
{ Broadcast |message ##| with value [3] }
{ Broadcast |message ##| with value [hello] }
{ Broadcast |message ## ##| with values [hello] , [world] }
{ Broadcast |add ## to ##| with values [-3.1] , [63.98] }
and it interprets any broadcast with a ## in it as including an attached value.
I'm not sure how you would get this to work well with putting an expression in the |message| field instead of selecting a dropdown... but you could probably make it work by doing it an entirely different way in which you don't have to attach a certain number of values to each broadcast, and you don't have to receive that number either.
anyways, to receiving:
:When I receive |message ##| , storing a value to |var1| :
:When I receive |message ##| , storing values to |var1| , |var2| :
so, what do you think?
Offline
HUGE SUPPORT!!!!
I've wanted this since forever and have tried coding it too.
Offline
I will add this to scratch suggestions then I guess...
I voted for http://suggest.scratch.mit.edu/forums/60449-suggestions/suggestions/1623323-broadcast-to-sprite?ref=title but now I'm out of votes.
Last edited by DarthPickley (2011-05-02 01:04:36)
Offline
Yesss, then Scratch would have something that are more like normal functions ie:
public class Hypotenuse {
public static double calculate(double a, double b) {
return Math.sqrt(a*a + b*b);
}
}
I do think it should be separate from broadcasts and not just an add on tho.
Offline
Or maybe just a (broadcasted value) reporter.
Offline
Issues with putting this as a broadcast would be that, many script can be activated by a broadcast, so which scripts get which variables?
I think this would be better as a build your own block feature.
Say this was not round but instead spin, a block that spins a sprite for the number of seconds you put in
<round( 3
This would spin for 3 seconds
You would also be able to build blocks that return values
<abs(
Offline
archmage wrote:
Yesss, then Scratch would have something that are more like normal functions ie:
public class Hypotenuse {
public static double calculate(double a, double b) {
return Math.sqrt(a*a + b*b);
}
}
I do think it should be separate from broadcasts and not just an add on tho.
well, if we were allowed to have Classes in Scratch, then, I mean, so much would be possible. Multiplayer would be simple: just create a new instance of a multiplayer group class. It would be like the clone block, but different... somehow.
but I highly doubt that scratch will support classes. BYOB3 doesn't even support classes.
well, I was thinking more like,
not only CALLING the phone number of the other sprite, but leaving it a message as well.
(see this to understand what I mean)
I mean, it is a way for two sprites to communicate with each other. It is just an improvement on broadcasts, you can broadcast "hello"
Offline
Ummm functions are different from classes, that was just a java example, and java requires you to do a class declaration to run that script.
Still the issue of multiple scripts that are called to with the same broadcast still creates an issue.
I understand your problem with the phone example and I think that custom blocks can provide a better solution. For example, a custom block for your example could look like this:
call (sprite dropdown menu) with message (insert text here)
Offline
archmage wrote:
Issues with putting this as a broadcast would be that, many script can be activated by a broadcast, so which scripts get which variables?
I think this would be better as a build your own block feature.
Say this was not round but instead spin, a block that spins a sprite for the number of seconds you put in
[blocks]
<round( 3
This would spin for 3 seconds
You would also be able to build blocks that return values
<abs([/blocks]
well, it would be good in BYOB, but I was just thinking that for the Receive hat block, I didn't want to have to do such foreign things as upvars, so I said, when I receive, store values into my variables.
It is like you are sending data from one sprite to another.
{ broadcast |Send ##| to |Sprite1| with value [10 5 25 90 3 24 6 9] }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When I receive |Send ##| and accept value to |var1|:
{ parse (var1) }
In BYOB3 actually, you have something called "launch" or "run", where you can essentially run or launch (run means wait until done; launch means don't wait) a block of another sprite, with inputs, or an input list. you can also call it.
Offline