Discuss Scratch

the_epic_joe
Scratcher
2 posts

clone massage

i have been running into a problem where clones are receiving massages from a normal when i recieve block and duplicating themselves or restarting a important script and i cant find a solution to this causing my game to have glitches.
awesome-llama
Scratcher
1000+ posts

clone massage

Ah yes… clone massages. It's very relaxing for the clones.

For your issue of having clones receiving messages, you need to make sure that there is a way to tell the diffrerence between a clone or the original sprite. The most common way of doing this is giving the clones IDs that are unique to their original. Say, clones have an ID of 1, and the original sprite has an ID of 0. This can be done by using local variables. These are the variables that are set to “this sprite only” which is set when they are created.


What this setting does is make that variable function differently. It no longer affects all clones and sprites at once. Instead, what is stored in the variable can be made unique to the clone or sprite that it is in.
For my example, the variable is named clone?, and uses the same 1 or 0 for identification like I mentioned before.

In your scripts, do something like this:
when green flag clicked
set [clone? v] to [0] // the original sprite always gets set to 0.

when I start as a clone // whenever a clone is created, set the variable to 1 (which will only be for itself)
set [clone? v] to [1]

Now, for broadcasts, all you have to do is check if the receiver is a clone or sprite like this:
when I receive [message v]
if <(clone?) = [0]> then // 0 means it is the original sprite, no clones will run anything in the if block
... // put your scripts here for the original sprite
end
the_epic_joe
Scratcher
2 posts

clone massage

thanks it works now

Powered by DjangoBB