# Accessing clone variables

Is there a way to have each clone of an object have a variable with a different value, but that can also be accessed outside the clone? For example, lets each clone have its own value of value, but does not work. Am I doing something wrong, or will I have to use a global list, with one item for each clone? Thanks!

if you use a sprite-only variable that same example should just work, and you can let other sprites access it using the ASK and OF reporters.

Thanks for the quick reply. However, now seems to make a different clone say its value every time. For example, when I run I get two clones, as expected. When I then click to run it, one sprite says its value, again as expected. However, If I drag and move the sprite with a speech bubble, then click again, the other clone says its value. Is the order of sprites in the list static, or is clicking the script to run it, instead of putting it under a hat block, doing something?

... which isn't what SCRIPT VARIABLES does.

Make a for-this-sprite-only variable in the parent sprite, and all the children will inherit it. (Actually if you make the variable in the parent before making the clones, it will be copied rather than inherited, which is what you want. If you make the variable after making the clones, there will just be one copy shared among all of them, but if you assign a new value to that variable in the clone, it gets its own copy split off from the parent, so that works for you too.)

That's what I'm doing in my second post. Sorry if it wasn't very clear.

Oops, sorry, I was answering your first post in parallel with you writing the second one.

From what you report, my guess would be that the clones are in layer order. Clicking on a sprite moves it to the front layer. Experiment and see if I'm right. :~)

You are right, but it seems to be backward from what you would expect. Telling a clone to go to the back layer actually moves it to the front of the list of clones.

The last to move is the first in the list of clone because it's on top...

I think

You can number the clones using a variable:

What a brilliantly simple solution

The clones, by default, are numbered in their parent's clone list, so you don't even have to access variables for that:

Nice but @loucheman method is VERY simple - I like simple

But, if you read the entire thread, the whole problem is that the clone list gets reordered sometimes, so you can't rely on it for a stable ID!

Create a sprite-local variable for the ID. You can increment it before/after each create a clone block, or tell my parent to increment it at the top of the when I start as a clone script.

This does it:

No, I do, too. (I try to make sure nobody else says something before I say it, but sometimes I miss something.)

I do (which is why I haven't said anything before)

@snapenilk @ego-lay_atman-bay Okay, sorry, I was feeling exasperated probably for reasons unrelated to the forum. (Such as the fact that in Alameda County they're still just doing age 75+ even though California is allowing 65+.) (Among other issues...)

It is what Joan said two, no, it's already three months ago, at GitHub - see the link below.

P.S.

Ah, would you mind if Joan's solutions were put in the FAQ category, copy pasted? Oh, and inserted into the next version of your official Manual, @bh ? Please.

It's the vaccination plans that you are talking about, aren't you?

I can empathize with you.

I can hardly wait to get it myself after my wife (who works in a hospital) has been vaccinated with the second dose of the Pfizer/BioNTech vaccine, already, with a slight fatigue as the only side-effect.

P.S.

But I will probably have to wait until summer because I am not a priority.