Discuss Scratch

BoyKetchup
Scratcher
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:
broadcast [ v]

broadcast [ v] and wait
and
when I receive [ v]

With the announcement system, there are also three blocks:
announce [ v] with information [] :: events

announce [ v] with information [] and wait :: events
and
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 reporter
The 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 [] :: events
Then you right click to change inputs, with a menu similar to custom blocks:
announce [move with speed v] with data: x: () y: () speed: () :: events
And you receive the announcement like this:
when [move with speed v] is announced with data: (x :: events) (y :: events) (speed :: events) :: events hat
And 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 hat
change [health v] by ((information :: events) * (-1)) // Using "information," The player removes the amount that is
// sent from its health.
You might think that you can just use this:
when this sprite clicked
set [damage v] to (pick random (4) to (6))
broadcast [hit v]

when I receive [hit v]
change [health v] by ((damage) * (-1))
The 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.


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)

seanbobe
Scratcher
500+ posts

I have an Announcement!

what can u use it for?
BoyKetchup
Scratcher
96 posts

I have an Announcement!

seanbobe wrote:

what can u use it for?
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)
BoyKetchup
Scratcher
96 posts

I have an Announcement!

BoyKetchup wrote:

seanbobe wrote:

what can u use it for?
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)
Using lists and variables to do this is rather complicated and glitchy.
PrincessPanda_test_
Scratcher
1000+ posts

I have an Announcement!

Support although this could be confusing.
Superbevzeeb
Scratcher
54 posts

I have an Announcement!

Not very glitchy if you use this method
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
Scratcher
1000+ posts

I have an Announcement!

Variables might work, but I see what you're saying. Semi-support.
pokejofe
Scratcher
68 posts

I have an Announcement!

Support
Pot-of-Gold
Scratcher
1000+ posts

I have an Announcement!

rollercoasterfan wrote:

Variables might work, but I see what you're saying. Semi-support.
TheUniversalWorld1
Scratcher
100+ posts

I have an Announcement!

What is the last block exactly mean?
when (information :: events) about [   v] is announced :: events hat
is
(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
Scratcher
96 posts

I have an Announcement!

Superbevzeeb wrote:

Not very glitchy if you use this method
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 wrote:

Variables might work, but I see what you're saying. Semi-support.
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.
BoyKetchup
Scratcher
96 posts

I have an Announcement!

TheUniversalWorld1 wrote:

What is the last block exactly mean?
when (information :: events) about [   v] is announced :: events hat
is
(information :: events)

supposed to be there, or do you mean:

when [] about [   v] is announced :: events hat
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.
Pot-of-Gold
Scratcher
1000+ posts

I have an Announcement!

TheUniversalWorld1 wrote:

What is the last block exactly mean?
when (information :: events) about [   v] is announced :: events hat
is
(information :: events)

supposed to be there, or do you mean:

when [] about [   v] is announced :: events hat
TheUniversalWorld1
Scratcher
100+ posts

I have an Announcement!

BoyKetchup wrote:

TheUniversalWorld1 wrote:

What is the last block exactly mean?
when (information :: events) about [   v] is announced :: events hat
is
(information :: events)

supposed to be there, or do you mean:

when [] about [   v] is announced :: events hat
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.
So the block is really
when [] about [   v] is announced :: events hat
with the information block being able to be put in there by the user, can the user type something in?
jvvg
Scratcher
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
Scratcher
96 posts

I have an Announcement!

TheUniversalWorld1 wrote:

BoyKetchup wrote:

TheUniversalWorld1 wrote:

What is the last block exactly mean?
when (information :: events) about [   v] is announced :: events hat
is
(information :: events)

supposed to be there, or do you mean:

when [] about [   v] is announced :: events hat
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.
So the block is really
when [] about [   v] is announced :: events hat
with the information block being able to be put in there by the user, can the user type something in?
No. Think about custom blocks:
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 hat
change [health v] by ((information :: events) * (-1))
In this case, “information” is being used to send the amount of damage being inflicted.

Last edited by BoyKetchup (June 18, 2015 23:19:23)

TheUniversalWorld1
Scratcher
100+ posts

I have an Announcement!

BoyKetchup wrote:

TheUniversalWorld1 wrote:

BoyKetchup wrote:

TheUniversalWorld1 wrote:

What is the last block exactly mean?
when (information :: events) about [   v] is announced :: events hat
is
(information :: events)

supposed to be there, or do you mean:

when [] about [   v] is announced :: events hat
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.
So the block is really
when [] about [   v] is announced :: events hat
with the information block being able to be put in there by the user, can the user type something in?
No. Think about custom blocks:
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.
I see, thanks for clarifying that.
thelucariokid
Scratcher
100+ posts

I have an Announcement!

I see how this could be used for clones. Support!
BoyKetchup
Scratcher
96 posts

I have an Announcement!

jvvg wrote:

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.
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.
iamunknown2
Scratcher
1000+ posts

I have an Announcement!

BoyKetchup wrote:

ANNOUNCING
announce information [] about [ v] :: events

announce information [] about [ v] and wait :: events
and
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 reporter
The 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
Easy workaround with custom and broadcast blocks.
No support.

Last edited by iamunknown2 (June 19, 2015 00:16:48)

Powered by DjangoBB