What is wrong with my script?

Here's the project

it's a custom variable watchers project that I've been working on

In the "create new variable watcher" block, it should create a clone of Sprite, with new clones of Sprite(2), Sprite(3), and Sprite(4) (yeah, bad names, I know) attached to it, but when I run the block, it creates too many clones. I've tried everything I can think of, but nothing seems to work even though when I think about the code for a long time, it shows no sign of creating too many clones.

I don't usually ask for help, but I'm really stumped right now.

Did you put a clone block under a hat?
If so,your clones will run this script and they will spam more clones.

no, why would I do that?

Okay, I found two problems, one of them small and one big.

The small one, in the sense that it's easy to fix, is that in the FOR EACH you have SET (MY ANCHOR) TO (). I think you think that the empty input slot will be filled by CLONE, since the FOR EACH is inside a TELL CLONE ... WITH INPUTS (CLONE). But FOR EACH also does the trick of filling empty input slots, so what's really going in the empty slot is the same as ITEM.

Nested rings (and the FOR EACH has an implicit ring around the C-slot, like all C-slots) are tricky. The way to fix it is to give the explicit gray ring in the TELL an explicit formal parameter, by clicking on its right arrowhead (not the TELL's right arrowhead -- the ring's one).

Okay, on to the big problem, and this surprised me too (blush): When you clone a sprite that has parts (other sprites) attached to it as anchor, it clones the parts as well. That's why you're getting extra clones of the other sprites. I'm not sure why you're getting extra clones of the main sprite, though.

I never knew that. Thanks.

also thanks.

Thank you so much. I learned a lot more than I knew before. Hopefully I get it to work.

You're welcome! I learned things too.

Wow, that's suprising. I never knew about that

@jens @jens @jens
:frowning: error fixing needed

Wait! What's the "error"? When you clone a composite sprite of course you want to clone the whole thing, including the parts, don't you agree?


I agree, there's no error in that.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.