Discuss Scratch

-Valtren-
Scratcher
1000+ posts

More clones than usual created when broadcast is received [RESOLVED]

My browser / operating system: MacOS Macintosh X 10.15.7, Opera 93.0.0.0, No Flash versions detected

Whenever I spawn clones from a broadcast, more are created than they are supposed to.
Steps to recreate: construct the below scripts:

when you click the broadcast once, my variable will be four, but when you click it twice, my variable will be 20. I tested this both on opera and safari.
here's another test using turbowarp's clone counter:

Last edited by -Valtren- (Jan. 4, 2023 05:38:08)

Monty017
Scratcher
71 posts

More clones than usual created when broadcast is received [RESOLVED]

Create the clones on another sprite or on the stage.

when I receive [whatever v]
create clone of [other sprite v]

On the other sprite that you want the clones to spawn from...

when I start as a clone
change [my variable v] by (1)

Last edited by Monty017 (Jan. 4, 2023 05:14:26)

SidewaysCoder
Scratcher
500+ posts

More clones than usual created when broadcast is received [RESOLVED]

I believe that this is a programming error. The four clones, including the main sprite itself, are each getting the broadcast to make four more clones. That explains the 4 to 24 clones: 4 (original clones) + 4 (clones created from parent sprite) + 4 (each of the 4 clones makes 4 clones) + 4 + 4 + 4 = 24.

One way you can solve this is by using these scripts instead, which will check if the sprite is a clone, and if so, to not clone itself:
when I receive [message1 v]
if <(am I a clone?) = (0)> then
create clone of [myself v]
create clone of [myself v]
create clone of [myself v]
create clone of [myself v]


when I start as a clone
set [am I a clone? v] to (1)
change [my variable v] by (1)

when green flag clicked
set [am I a clone? v] to (0)
The “am I a clone?” variable should be “for this sprite only”.

Powered by DjangoBB