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

#1 2011-06-25 17:13:05

quincyM
Scratcher
Registered: 2011-06-18
Posts: 19

When sprite created / variable Message head block

I'd like a message received block which catches when the sprite has been cloned/created.  Additionally a block : "when message <variable> received"

how i imagine the blocks being used:

when green flag pressed.
   set <numOfClones> to 0.
   <clone>

when cloned
   set <spriteId> to <numOfClones>
   change <numOfClones> by 1.

when message < join <"hello", spriteId> > received
   say < join <"I'm clone with id:", spriteId> >


Why is this useful?  Now you can manage 1 specific clone.  The way we have to handle this now is duplicate the sprite and make new messages, like "hello1","hello2","hello3"  for 3 duplicate sprites.

Offline

 

#2 2011-06-25 18:03:27

quincyM
Scratcher
Registered: 2011-06-18
Posts: 19

Re: When sprite created / variable Message head block

a problem i didn't consider:  many blocks only refer to a sprite name.
many sprites could exist which have the same name.

for example, if touching "bird"   would check if touching any birds rather than a specific cloned bird. 

i'm sure there are many ways to think about to solve all these cloning blocks issues.

1 set of new suggestions:

* Every sprite has a read-only variable called "id" which scratch sets as a unique number when sprite is cloned/created.
* BLOCK < Each Referring Clone >  which is an variable list block containing all the clone's ids of the last block which referred to the sprite's name.
* A new message receiving block: "When signal <messageName> received".  A signal is a message for specifically  one unique clone.
* A new message sending block which has two inputs: "signal <messageName> , <id>"
* A new loop block which has two inputs: "For each <item> , <list>".  this would allow you to loop through each item of a list more easily.

new blocks using example:

When green flag pressed
   Clone
   set <touchingId> to 0.
   forever
      if <touching <"SpriteName"> >
            for each <touchingId> , < Each Referring Clone >
                signal "hello", touchingId


when signal "hello" received
   say "hello, another clone is touching me"

does this make sense?

Offline

 

#3 2011-06-25 22:49:28

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: When sprite created / variable Message head block

This seems to be assuming Scratch has sprite cloning features - which it currently does not.  wink  I think the Scratch Team is considering it but still has some qualms about how it would work. This definitely seems like a good way to handle clones if the feature is implemented though.

Last edited by Harakou (2011-06-25 22:50:05)


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#4 2011-06-26 01:28:30

quincyM
Scratcher
Registered: 2011-06-18
Posts: 19

Re: When sprite created / variable Message head block

yeah thanks.  its not as simple as just adding one block for cloning to work.  i wonder if there is an easier way / less blocks way.

Offline

 

#5 2011-06-26 01:31:38

veggieman001
Scratcher
Registered: 2010-02-20
Posts: 1000+

Re: When sprite created / variable Message head block

Cloning is implemented in the project creator pre-alpha.


Posts: 20000 - Show all posts

Offline

 

#6 2011-06-26 01:48:35

quincyM
Scratcher
Registered: 2011-06-18
Posts: 19

Re: When sprite created / variable Message head block

yeah i know, but since its still not a confirmed feature, they are most likely worried about how the existing blocks would work with cloning.

Offline

 

Board footer