Discuss Scratch

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

PvZ_Peashooters wrote:

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

NMario84 wrote:

The issue here is that you don't change the clone ID ‘AS’ the clone. You change it BEFORE you create the clone.
~snip~
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.
PvZ_Peashooters
Scratcher
4 posts

Individual Clone IDs

Oh ok

NMario84 wrote:

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

Catscratcher07 wrote:

NMario84 wrote:

The issue here is that you don't change the clone ID ‘AS’ the clone. You change it BEFORE you create the clone.
~snip~
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.
Your method should be fine but there's no need normally for an ‘isClone’ variable so your ‘clones’ variable is an additional variable.
Catscratcher07
Scratcher
1000+ posts

Individual Clone IDs

deck26 wrote:

Catscratcher07 wrote:

NMario84 wrote:

The issue here is that you don't change the clone ID ‘AS’ the clone. You change it BEFORE you create the clone.
~snip~
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.
Your method should be fine but there's no need normally for an ‘isClone’ variable so your ‘clones’ variable is an additional variable.
The “isClone?” variable is necessary for distinguishing between clones and the main sprite with his method, which you usually need to do.
Turbo_yeeter
Scratcher
100+ posts

Individual Clone IDs

Catscratcher07 wrote:

-snip- (#9)
The “isClone?” variable is necessary for distinguishing between clones and the main sprite with his method, which you usually need to do.
No, it isn't. You can simply have
if <(CloneId) = [(insert original sprite id here)]> then
do stuff
else
do clone stuff
end
Catscratcher07
Scratcher
1000+ posts

Individual Clone IDs

Turbo_yeeter wrote:

Catscratcher07 wrote:

-snip- (#9)
The “isClone?” variable is necessary for distinguishing between clones and the main sprite with his method, which you usually need to do.
No, it isn't. You can simply have
if <(CloneId) = [(insert original sprite id here)]> then
do stuff
else
do clone stuff
end
NMario's method has the main sprite constantly having the id of the most recent clone, so that would not work.
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

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 clicked
say (id)
you should get its individual id, hope that helped, will be on it for further discussion btw
Catscratcher07
Scratcher
1000+ posts

Individual Clone IDs

NMario84 wrote:

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.

~snip~
what if you don't want all your clones created at once?

jcboi123 wrote:

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
~snip~
you should get its individual id, hope that helped, will be on it for further discussion btw
This would give the main sprite id 1 (which is weird, but fine) and every clone id 2.

Powered by DjangoBB