Communicate local variable value from a sprite clone to other different sprite

Hi! I cant figure out to do this:
a) Imagine that I have clones from the same sprite, lets say, cats.
b) The cats have a Local Variable like energy (for example EnergCat). Its random and unique for each cat as they born as clones.
c) Now there are clones of dogs (from other sprite) near the cats.
d) Dogs will attack the nearest cat only if EnergCat is less than a given value, 10 for instance.
e) How can I make a script for the dogs know the EnergCat, since thats specific and local? I mean, in the scripts for the dog, I cant find the EnergCat...

I hope I was clear lol. Thanks!!

Do this to find out the value of EnergCat in another sprite:
image
You can get any named variable by right-clicking a variable block and choosing "rename". Once in the dialog, type "EnergCat" or whatever the name is. Then put the variable inside a ring and put the ring in the script above.

Hi! IT says "Error, a variable of EnergCat" does not exist in this context..."

By the way, its not about dogs and cats, I am doing other thing but in order to explain it better I used that example. Anyway, Something is not working...

Replace EnergCat with the name of the local variable you're trying to get, and replace the block that says "desired clone of cat sprite" with whatever function you're using to get the clone or sprite.

use this


and if you know which sprite it is, just replace the item of block with the sprite (clone). btw, you need to use the clone object in order to get the value for the clone. Using just the name will result in the sprite's (not clone) variable.

oh, and to get the first option, just select the sprite in the second input, then select the variable name in the first input, then put the reporter with the clone in the second input. You can also just stick a join block in the first option to type out the variable name instead of selecting it.

That part I understood, replacing things accordingly the variable names I used. :smiley:
Neverthless, I found the error I said before. I will check again what you said, during the weekedn I will have some time to see it.

Curious script, I will try it!

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