Discuss Scratch
- BoyKetchup
-
96 posts
I have an Announcement!
ANNOUNCING
When you broadcast a message, you can activate another script, but you can't send other information. You can try to send data by storing it in a variable, but if you have multiple sprites trying to do the same thing, then it doesn't work so well. I want the scratch team to add a system called “announcing.” Here is the idea:
In the broadcast system, there are three blocks:
With the announcement system, there are also three blocks:
When a sprite receives an announcement, it also gets the information that came with it.
Example:
Enemy Script:
Player Script:
Please tell me what you think and try to think of any improvements that can be made. If you think there is a workaround, please explain it. Most people think of the same one, which is described above. That system is buggy, and does not work sometimes, which is why I posted this idea.
Uses:
Supporters:
When you broadcast a message, you can activate another script, but you can't send other information. You can try to send data by storing it in a variable, but if you have multiple sprites trying to do the same thing, then it doesn't work so well. I want the scratch team to add a system called “announcing.” Here is the idea:
In the broadcast system, there are three blocks:
broadcast [ v]and
broadcast [ v] and wait
when I receive [ v]
With the announcement system, there are also three blocks:
announce [ v] with information [] :: eventsand
announce [ v] with information [] and wait :: events
when (information :: events) about [ v] is announced :: events hat
When a sprite receives an announcement, it also gets the information that came with it.
information :: events reporterThe sprite is able to access the information through the reporter in the hat block. You can drag it out of the hat block to make a copy (like with custom block inputs). @stickfiregames suggested in this forum that as a possible feature you can right click to change the amount, names, and types of inputs (like custom blocks), making it look like this:
announce [move with speed v] with data: information [] :: eventsThen you right click to change inputs, with a menu similar to custom blocks:
announce [move with speed v] with data: x: () y: () speed: () :: eventsAnd you receive the announcement like this:
when [move with speed v] is announced with data: (x :: events) (y :: events) (speed :: events) :: events hatAnd each announcement could have a different set of inputs. Please tell me if you support this version, and I will change the main post.
Example:
Enemy Script:
when green flag clicked
forever
if <touching [player v] ?> then // When enemy collides with player...
announce [enemy hit v] with information (pick random (4) to (6)) :: events // Tell the player to subtract a number
// from 4 to 6 from its health.
end
end
Player Script:
when (information :: events) about [enemy hit v] is announced :: events hatYou might think that you can just use this:
change [health v] by ((information :: events) * (-1)) // Using "information," The player removes the amount that is
// sent from its health.
when this sprite clickedThe reason that doesn't work is because, when you have a ton of clones all doing the same thing, sometimes they will do it at the same time and override each other's information before the other sprite can do anything with it.
set [damage v] to (pick random (4) to (6))
broadcast [hit v]
when I receive [hit v]
change [health v] by ((damage) * (-1))
Please tell me what you think and try to think of any improvements that can be made. If you think there is a workaround, please explain it. Most people think of the same one, which is described above. That system is buggy, and does not work sometimes, which is why I posted this idea.
Uses:
- Getting information about private variables inside clones (this itself could be used for multiple things)
- Differentiating between multiple clones
- Removing the need for multiple public variables, which clutter your project, and don't work well anyways (see above)
Supporters:
- PrincessPanda_test_
- rollercoasterfan
- pokejofe
- thelucariokid
- Pot-of-Gold
- BlueCrayfish
- matey1234
- Superbevzeeb
- Rex208
- EmeraldSapphire41
Last edited by BoyKetchup (June 20, 2015 01:35:52)
- BoyKetchup
-
96 posts
I have an Announcement!
When you have multiple clones of a sprite (say, a missile) and they are colliding with one sprite, they can tell that sprite their location (so that it can calculate an explosion and where it needs to move) what can u use it for?
- BoyKetchup
-
96 posts
I have an Announcement!
Using lists and variables to do this is rather complicated and glitchy.When you have multiple clones of a sprite (say, a missile) and they are colliding with one sprite, they can tell that sprite their location (so that it can calculate an explosion and where it needs to move) what can u use it for?
- PrincessPanda_test_
-
1000+ posts
I have an Announcement!
Support although this could be confusing.
- Superbevzeeb
-
54 posts
I have an Announcement!
Not very glitchy if you use this method
could be useful though
set [missile x] to (x position)
set [missile y] to (y position)
when I receive [missile impact]
go to x: (missile x) y: (missile y)
switch costume to [explosion]
could be useful though
- rollercoasterfan
-
1000+ posts
I have an Announcement!
Variables might work, but I see what you're saying. Semi-support.
- Pot-of-Gold
-
1000+ posts
I have an Announcement!
Variables might work, but I see what you're saying. Semi-support.
- TheUniversalWorld1
-
100+ posts
I have an Announcement!
What is the last block exactly mean?
supposed to be there, or do you mean:
when (information :: events) about [ v] is announced :: events hatis
(information :: events)
supposed to be there, or do you mean:
when [] about [ v] is announced :: events hat
Last edited by TheUniversalWorld1 (June 18, 2015 23:06:30)
- BoyKetchup
-
96 posts
I have an Announcement!
Not very glitchy if you use this methodset [missile x] to (x position)
set [missile y] to (y position)when I receive [missile impact]
go to x: (missile x) y: (missile y)
switch costume to [explosion]
could be useful though
The reason variables don't work very well (including Superbevzeeb's method) is because, when you have multiple clones, they sometimes override each other's data before it can be used. Variables might work, but I see what you're saying. Semi-support.
- BoyKetchup
-
96 posts
I have an Announcement!
Yes, that block is supposed to be there. It's like the inputs for custom blocks: you drag it out of the hat block to make a copy you can use. What is the last block exactly mean?when (information :: events) about [ v] is announced :: events hatis(information :: events)
supposed to be there, or do you mean:when [] about [ v] is announced :: events hat
- Pot-of-Gold
-
1000+ posts
I have an Announcement!
What is the last block exactly mean?when (information :: events) about [ v] is announced :: events hatis(information :: events)
supposed to be there, or do you mean:when [] about [ v] is announced :: events hat
- TheUniversalWorld1
-
100+ posts
I have an Announcement!
So the block is reallyYes, that block is supposed to be there. It's like the inputs for custom blocks: you drag it out of the hat block to make a copy you can use. What is the last block exactly mean?when (information :: events) about [ v] is announced :: events hatis(information :: events)
supposed to be there, or do you mean:when [] about [ v] is announced :: events hat
when [] about [ v] is announced :: events hatwith the information block being able to be put in there by the user, can the user type something in?
- jvvg
-
1000+ posts
I have an Announcement!
This could be useful, though custom blocks are a limited equivalent that can run inside one sprite. I think a better alternative would simply be global custom blocks.
- BoyKetchup
-
96 posts
I have an Announcement!
No. Think about custom blocks:So the block is reallyYes, that block is supposed to be there. It's like the inputs for custom blocks: you drag it out of the hat block to make a copy you can use. What is the last block exactly mean?when (information :: events) about [ v] is announced :: events hatis(information :: events)
supposed to be there, or do you mean:when [] about [ v] is announced :: events hatwhen [] about [ v] is announced :: events hatwith the information block being able to be put in there by the user, can the user type something in?
define drift to x:(x target) y:(y target)You drag out the “x target” and “y target” reporters to use them, but the originals stay in the hat block:
when (information :: events) about [sprite damaged v] is announced :: events hatIn this case, “information” is being used to send the amount of damage being inflicted.
change [health v] by ((information :: events) * (-1))
Last edited by BoyKetchup (June 18, 2015 23:19:23)
- TheUniversalWorld1
-
100+ posts
I have an Announcement!
I see, thanks for clarifying that.No. Think about custom blocks:So the block is reallyYes, that block is supposed to be there. It's like the inputs for custom blocks: you drag it out of the hat block to make a copy you can use. What is the last block exactly mean?when (information :: events) about [ v] is announced :: events hatis(information :: events)
supposed to be there, or do you mean:when [] about [ v] is announced :: events hatwhen [] about [ v] is announced :: events hatwith the information block being able to be put in there by the user, can the user type something in?define drift to x:(x target) y:(y target)You drag out the “x target” and “y target” reporters to use them, but the originals stay in the hat block.
- thelucariokid
-
100+ posts
I have an Announcement!
I see how this could be used for clones. Support!
- BoyKetchup
-
96 posts
I have an Announcement!
The issue with that is custom blocks are meant to teach the idea of functions, which, in real code, can only change the variables of the object they run from. Calling a function of one sprite from another would only affect the variables in the sprite calling it. That also brings up issues of them having different private variables. This could be useful, though custom blocks are a limited equivalent that can run inside one sprite. I think a better alternative would simply be global custom blocks.
- iamunknown2
-
1000+ posts
I have an Announcement!
ANNOUNCINGEasy workaround with custom and broadcast blocks.announce information [] about [ v] :: eventsand
announce information [] about [ v] and wait :: eventswhen (information :: events) about [ v] is announced :: events hat
When a sprite receives an announcement, it also gets the information that came with it.information :: events reporterThe sprite is able to access the information through the reporter in the hat block. You can drag it out of the hat block to make a copy (like with custom block inputs).
Example:
Enemy Script:when green flag clicked
forever
if <touching [player v] ?> then // When enemy collides with player...
announce information (pick random (4) to (6)) about [enemy hit v] :: events // Tell the player to subtract a number from 4 to 6 from its health.
end
end
Player Script:when (information :: events) about [enemy hit v] is announced :: events hat
change [health v] by ((information :: events) * (-1)) // Using "information," The player removes the amount it is sent from its health.
Please tell me what you think and try to think of any improvements that can be made.
Uses:
- Getting information about private variables inside clones (this itself could be used for multiple things)
Supporters:
- PrincessPanda_test_
- rollercoasterfan
- pokejofe
- thelucariokid
No support.
Last edited by iamunknown2 (June 19, 2015 00:16:48)