Discuss Scratch

perrys25
Scratcher
3 posts

Clone ID

I Think there should be a id for each clone (Clone id) that you could use to separate what each clone does
whenIstartasacloneifCloneID=1thenDoBlaBlaBla4
Harakou
Scratcher
1000+ posts

Clone ID

Before anyone says it, yes I know this thread said it was created by me. I transplanted this from a completely unrelated thread it was originally posted in, and that requires me to first make a thread and move the post to it, then delete my OP. Please keep discussion about the idea and not DjangoBB's quirks.

This is an interesting idea! Having some kind of way to identify clones is potentially useful and is a pretty common idea in other languages - I'm interested what similar solutions the community has already devised.

Last edited by Harakou (Sept. 8, 2018 17:02:51)

VideoGamerCanInvent
Scratcher
1000+ posts

Clone ID

Harakou wrote:

Before anyone says it, yes I know this thread said it was created by me. I transplanted this from a completely unrelated thread it was originally posted in, and that requires me to first make a thread and move the post to it, then delete my OP.

This is an interesting idea! Having some kind of way to identify clones is potentially useful and is a pretty common idea in other languages - I'm interested what similar solutions the community has already devised.
Ohhhh. I got confused XD
red_king_cyclops
Scratcher
500+ posts

Clone ID

Clone IDs are already possible using local variables, but it's not an obvious way.

Last edited by red_king_cyclops (Sept. 8, 2018 17:49:32)

Wahsp
Scratcher
1000+ posts

Clone ID

red_king_cyclops wrote:

Clone IDs are already possible using local variables, but it's not an obvious way.
It's not that hard, I do it all the time

Whenever you create a clone you have to change the ID
Here's an example of what I would do:

setclone IDto0repeat--createcloneofthis spritechangeclone IDby1whenIstartasacloneifcloneID=1then. . .whenIstartasacloneifcloneID=2then. . .
red_king_cyclops
Scratcher
500+ posts

Clone ID

Wahsp wrote:

red_king_cyclops wrote:

Clone IDs are already possible using local variables, but it's not an obvious way.
It's not that hard, I do it all the time

Whenever you create a clone you have to change the ID
Here's an example of what I would do:

setclone IDto0repeat--createcloneofthis spritechangeclone IDby1whenIstartasacloneifcloneID=1then. . .whenIstartasacloneifcloneID=2then. . .
I did not mean that it is hard to make clone IDs with local variables, I meant that it is not obvious that you use local variables to make clone IDs. It took me many months before I found out that local variables can be used to make clone IDs. How was I supposed to know that local variables have something to do with clones?
badatprogrammingibe
Scratcher
500+ posts

Clone ID

Wahsp wrote:

red_king_cyclops wrote:

Clone IDs are already possible using local variables, but it's not an obvious way.
It's not that hard, I do it all the time

Whenever you create a clone you have to change the ID
Here's an example of what I would do:

setclone IDto0repeat--createcloneofthis spritechangeclone IDby1whenIstartasacloneifcloneID=1then. . .whenIstartasacloneifcloneID=2then. . .
Whether its easy is irrelevant to how obvious it is.
For example, it's easy to get the warp flute in Mario Bros 3, but to someone who wasn't told how, they most likely wouldn't be able to find it.

What I suggest is an easier way to find out about how local variables work with relation to clones, rather than adding a new feature entirely.

Last edited by badatprogrammingibe (Sept. 9, 2018 03:23:39)

KJRYoshi07
Scratcher
1000+ posts

Clone ID

Support, it will help people who don't exactly know cloning yet, and also people who want the clones to do different things without using more sprites.
Just having a variable isn't the obvious way, and it would definitely take longer.

Last edited by KJRYoshi07 (Sept. 9, 2018 03:07:48)

DaEpikDude
Scratcher
1000+ posts

Clone ID

badatprogrammingibe wrote:

Whether its easy is irrelevant to how obvious it is.
For example, it's easy to get the warp flute in Mario Bros 3, but to someone who wasn't told how, they most likely wouldn't be able to find it.

What I suggest is an easier way to find out about how local variables work with relation to clones, rather than adding a new feature entirely.
^ Definitely this.
Although the help feature is kind of hidden I think that the help for the “create clone of ___” block should make a mention about local variables.

Last edited by DaEpikDude (Sept. 9, 2018 06:59:28)

TheLogFather
Scratcher
1000+ posts

Clone ID

This kind of thing has been suggested numerous times before. Here are a few examples:
https://scratch.mit.edu/discuss/topic/6508/
https://scratch.mit.edu/discuss/topic/9318/
https://scratch.mit.edu/discuss/topic/124500/
https://scratch.mit.edu/discuss/topic/184244/
https://scratch.mit.edu/discuss/topic/244243/
https://scratch.mit.edu/discuss/topic/304387/


TBH, though, I don't understand how it's that different from just having a global counter that you increase by one for each clone that's made, and have a “this sprite only” variable that takes the value of that global when a clone gets created:

whenclickedsetclone counterto0dosomestuff...createcloneofmyself at some pointdosomeotherstuff...whenIstartasaclonechangeclone counterby1 increase this for each new clonesetclone IDtoclonecounter now the clone has a unique IDdosomestuffbasedoncloneID...


However, I think what you really want to know isn't so much what a clone's number is, but what a clone is meant to *do* – and you can tell it that by setting a local ‘this sprite only’ variable (or several, if necessary) to some appropriate identifier info before starting a new clone.

This is much more general, allowing you to decide for yourself exactly how a clone identification system is going to work for your particular project.

For example:

whenclickedsetclone behaviourtocreator this is to identify the original sprite (that creates things as clones)hide the original sprite may not need to be visible – it just creates things that are shownmoreinitialisationforthiscreatorspritewhenIreceivestart game perhaps a broadcast sent from some menu system (e.g. a "start" button)repeatuntilgameover=yesifit'stimeforanewenemytype2toappearthensetclone behaviourtoenemy type 2 set it temporarily to tell new clone what type of thing it iscreatecloneofmyself note that "clone behaviour" above is a local variablesetclone behaviourtocreator now set it back for the creator spritewhateverelsethecreatorspritedoes...whenIstartasacloneifclonebehaviour=enemy type 1thenwhateverinitialisationisneededforthistypeofclone... e.g. position, costume, etc.show probably needs to show at some pointrepeatuntilgameover=yeswhateverbehaviourtype1shouldhave... could maybe do it like this...elseifclonebehaviour=enemy type 2theninitialisethiscloneinwhateverway...repeatuntiltouchingedge?whateverbehaviourtype2shouldhave...ifgameover=yesthendeletethisclone perhaps it also needs to go away once game is over maybe this enemy does something like this...elseetc...deletethisclone should usually delete clone once done with itwhenIreceivetell everything something happened... clones also respond to broadcastsifclonebehaviour=enemy type 1thenetc... so you can have different types of clone react in different ways...

As others have mentioned above, though, I do think it's not immediately obvious that a ‘this sprite only’ variable also means each clone has its own independent value for such a variable. Too often a clone is kinda thought of as being a ‘part’ of the sprite it came from, rather than being a sprite in its own right. (I mean, a clone of a sprite is also a sprite, after all!)

It would be nice to see some reference to such things in the help, if possible.

Anyway, hopefully there might be some useful ideas somewhere in there.

Last edited by TheLogFather (Sept. 9, 2018 14:54:25)

Paddle2See
Scratch Team
1000+ posts

Clone ID

TheLogFather wrote:

This kind of thing has been suggested numerous times before. Here are a few examples:
https://scratch.mit.edu/discuss/topic/6508/
https://scratch.mit.edu/discuss/topic/9318/
https://scratch.mit.edu/discuss/topic/124500/
https://scratch.mit.edu/discuss/topic/184244/
https://scratch.mit.edu/discuss/topic/244243/
https://scratch.mit.edu/discuss/topic/304387/
<snip>
Thanks for the link and the awesome work-arounds! It does look like this is a duplicate topic so I'll close it to keep the conversation all in one place.

Please use the oldest existing topic in the links above - I'll start consolidating them back to that one.

Powered by DjangoBB