Discuss Scratch
- Discussion Forums
- » Questions about Scratch
- » Clone Special Ids
- LanceZealot
-
7 posts
Clone Special Ids
I know how to give clones ids.
However my question is…
How do I make it so two clones don't have the same id?
However my question is…
How do I make it so two clones don't have the same id?
- powercon5
-
1000+ posts
Clone Special Ids
You need to declare the id variable as “for this sprite only” the clone will then have an independently acting variable, set to whatever the base value was when the clone was created.
- LanceZealot
-
7 posts
Clone Special Ids
Yeah but I mean by
I give each clone a certain ID
Each ID will do different things
But I don't want two clones having the same ID
Maybe you already answered it
But still this is what I mean
I give each clone a certain ID
Each ID will do different things
But I don't want two clones having the same ID
Maybe you already answered it
But still this is what I mean
- -ShadowOfTheFuture-
-
1000+ posts
Clone Special Ids
This is a bit messy… I haven't tested it, but I think it might work.
Basically, each clone ID is stored in a list, so there will be no duplicates.
Basically, each clone ID is stored in a list, so there will be no duplicates.
when green flag clicked
forever
delete (all v) of [clone_list v]
if <something :: #999999> then
create clones () // whatever # of clones you need
end
broadcast [update clone_list v] and wait
end
when I receive [update clone_list v]
if <not <(clone_ID) = [0]>> then
add (clone_ID) to [clone_list v]
end
// below custom block is "run w/o screen refresh"
define create clones (#)
set [clone_ID v] to [0] // must be a local variable
repeat (#) // # of clones you need
repeat until <not <[clone_list v] contains (clone_ID) ?>>
change [clone_ID v] by (1)
end
create clone of [myself v]
end
set [clone_ID v] to [0]
when I start as a clone
if <(clone_ID) = [1]> then
do something :: #999999
end
if <(clone_ID) = [2]> then
do something else :: #999999
end
... // as many as you need
Last edited by -ShadowOfTheFuture- (Oct. 25, 2018 23:58:56)
- LanceZealot
-
7 posts
Clone Special Ids
I will try this.
Thank you very much!
Thank you very much!
when I receive [Help]
say [Thank you very much!]
- -ShadowOfTheFuture-
-
1000+ posts
Clone Special Ids
Keep in mind that the script will set the clone to the lowest available number for its ID, though, which might affect your project.
- Discussion Forums
- » Questions about Scratch
-
» Clone Special Ids