Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Individual Clone IDs
- PvZ_Peashooters
-
Scratcher
4 posts
Individual Clone IDs
I know it's possible to make a clone hold on to 1 ID (theirs) and only 1 (theirs). But how do I do it?
- Catscratcher07
-
Scratcher
1000+ posts
Individual Clone IDs
when I start as a clone
change [clones v] by [1] //initialize this to zero at the start of the project
set [clone id v] to (clones) // for this sprite only
- PvZ_Peashooters
-
Scratcher
4 posts
Individual Clone IDs
Yeah, but I already tried something like that. The clone ID changes and then the clones all get the same ID.
- Catscratcher07
-
Scratcher
1000+ posts
Individual Clone IDs
Yeah, but I already tried something like that. The clone ID changes and then the clones all get the same ID.Sounds like you are forgetting to mark clone id as “for this sprite only.”
- NMario84
-
Scratcher
1000+ posts
Individual Clone IDs
The issue here is that you don't change the clone ID ‘AS’ the clone. You change it BEFORE you create the clone.
when green flag clicked
set [clone ID v] to (0) // make variable "for this sprite only"
repeat [#]
change [clone ID v] by (1)
create clone of [myself v]
end
forever
do other stuff
...
end
when I start as a clone
go to [random position v]
say (Clone ID)
Last edited by NMario84 (March 8, 2025 21:34:04)
- Catscratcher07
-
Scratcher
1000+ posts
Individual Clone IDs
The issue here is that you don't change the clone ID ‘AS’ the clone. You change it BEFORE you create the clone.My method of incrementing a “clones” variable in the clone script then setting the clone id to that is valid, it does not result in an extra variable since it removes the need for an “isClone?” variable.
~snip~
- PvZ_Peashooters
-
Scratcher
4 posts
Individual Clone IDs
Oh ok
The issue here is that you don't change the clone ID ‘AS’ the clone. You change it BEFORE you create the clone.when green flag clicked
set [clone ID v] to (0) // make variable "for this sprite only"
repeat [#]
change [clone ID v] by (1)
create clone of [myself v]
end
forever
do other stuff
...
end
when I start as a clone
go to [random position v]
say (Clone ID)
- deck26
-
Scratcher
1000+ posts
Individual Clone IDs
Your method should be fine but there's no need normally for an ‘isClone’ variable so your ‘clones’ variable is an additional variable.The issue here is that you don't change the clone ID ‘AS’ the clone. You change it BEFORE you create the clone.My method of incrementing a “clones” variable in the clone script then setting the clone id to that is valid, it does not result in an extra variable since it removes the need for an “isClone?” variable.
~snip~
- Catscratcher07
-
Scratcher
1000+ posts
Individual Clone IDs
The “isClone?” variable is necessary for distinguishing between clones and the main sprite with his method, which you usually need to do.Your method should be fine but there's no need normally for an ‘isClone’ variable so your ‘clones’ variable is an additional variable.The issue here is that you don't change the clone ID ‘AS’ the clone. You change it BEFORE you create the clone.My method of incrementing a “clones” variable in the clone script then setting the clone id to that is valid, it does not result in an extra variable since it removes the need for an “isClone?” variable.
~snip~
- Turbo_yeeter
-
Scratcher
100+ posts
Individual Clone IDs
-snip- (#9)No, it isn't. You can simply have
The “isClone?” variable is necessary for distinguishing between clones and the main sprite with his method, which you usually need to do.
if <(CloneId) = [(insert original sprite id here)]> then
do stuff
else
do clone stuff
end
- Catscratcher07
-
Scratcher
1000+ posts
Individual Clone IDs
NMario's method has the main sprite constantly having the id of the most recent clone, so that would not work.-snip- (#9)No, it isn't. You can simply have
The “isClone?” variable is necessary for distinguishing between clones and the main sprite with his method, which you usually need to do.if <(CloneId) = [(insert original sprite id here)]> then
do stuff
else
do clone stuff
end
- NMario84
-
Scratcher
1000+ posts
Individual Clone IDs
Whats the issue here? If you want the base sprite return the ‘CloneID’ variable back to 0, you just insert another block right after the clones are done being created.
when green flag clicked
set [clone ID v] to (0) // make variable "for this sprite only"
repeat [#]
change [clone ID v] by (1)
create clone of [myself v]
end
set [clone ID v] to (0) // Sets the clone ID back to 0, assuming this is still the main sprite.
- jcboi123
-
Scratcher
64 posts
Individual Clone IDs
I am about to blow yall's minds,
Here is the script for initialization in the clone sprite, as the ID variable is a local variable
now, you can swap the green flag for whatever hat block, and you can spawn a clone elsewhere, just make sure your clones have this script
now when you ask the clone what its id is via a script like this
Here is the script for initialization in the clone sprite, as the ID variable is a local variable
when green flag clicked
set [id] to [1]
create clone of [ (sprite you want) ]
now, you can swap the green flag for whatever hat block, and you can spawn a clone elsewhere, just make sure your clones have this script
when I start as a clone
change [id] by (1)
now when you ask the clone what its id is via a script like this
when this sprite clickedyou should get its individual id, hope that helped, will be on it for further discussion btw
say (id)
- Catscratcher07
-
Scratcher
1000+ posts
Individual Clone IDs
Whats the issue here? If you want the base sprite return the ‘CloneID’ variable back to 0, you just insert another block right after the clones are done being created.what if you don't want all your clones created at once?
~snip~
I am about to blow yall's minds,This would give the main sprite id 1 (which is weird, but fine) and every clone id 2.
Here is the script for initialization in the clone sprite, as the ID variable is a local variable
~snip~
you should get its individual id, hope that helped, will be on it for further discussion btw
- Discussion Forums
- » Help with Scripts
-
» Individual Clone IDs





