Discuss Scratch

Yoshiii999
Scratcher
100+ posts

Minimum requirements for a "for this sprite only" variable to be accessed by clones

What are the minimum requirements for a “for this sprite only” variable's value in the main sprite to be accessed and changed by clones?

#signature
yes my signature is bigger than this, select a piece of text and use shift+down to scroll through it


I reside at www.npxl32.com, with the www because it won't work otherwise.

















i like Microsoft

(download this and upload it as a sprite to scratch): https://backpack.scratch.mit.edu/f1eceb3e927259af33ebc9ec27d72d6b.zip
mstone326
Scratcher
1000+ posts

Minimum requirements for a "for this sprite only" variable to be accessed by clones

The minimal requirement is a “for this sprite only” variable.

Here is an example, each clone has a health value from the “this sprite only” variable. As you click each one they can change the value of their health.
https://scratch.mit.edu/projects/324509574

Here is a project I made during Getting Unstuck with teachers group. This uses an id system so each clone has a number, then each of the for this sprite only values are changed in the lists. Press space to see the list of values changing. All variables are “for this sprite only” the lists are "for all sprites'
https://scratch.mit.edu/projects/411989483

High School Athletic Director / Middle School Tech Teacher / High School Baseball Coach
Kung Fu by Nintendo 1984 - https://scratch.mit.edu/projects/369994801/
Taco Defense - Speed Typing - https://scratch.mit.edu/projects/316795450/
Halloween Boss Battle - Taking Back our Woods - https://scratch.mit.edu/projects/257155118/
Almost Pong - https://scratch.mit.edu/projects/656276979/
Studio - My Best Projects - https://scratch.mit.edu/studios/4125978/
Forum Help Project Examples - https://scratch.mit.edu/studios/4133335
Yusei-Fudo
Scratcher
1000+ posts

Minimum requirements for a "for this sprite only" variable to be accessed by clones

Can you explain a little more about what you mean?

I'm a decent coder who has a huge passion for coding. I taught myself all the coding skills I have now. And with those skills, I have made some pretty decent projects, check them out! Be sure to ⭐ ❤️ & Follow, too! I have a few pictures below which are actually links. Click on them to take to different projects that I made. Might come in handy. :)

Need a project where you can check to see if you can use someone's camera or not? Here's one:


Need a project to detect when someone has clicked the stop sign? Take a look at this:

Need a project that can point at specific clones, etc? Why not use this:


Need to prank someone? Tell them to click this picture, but also make sure they're signed onto Scratch, otherwise, it doesn't work:


For more of my projects, just click on this picture:
Yoshiii999
Scratcher
100+ posts

Minimum requirements for a "for this sprite only" variable to be accessed by clones

Yusei-Fudo wrote:

Can you explain a little more about what you mean?
Like for some for-this-sprite-only variables, there is a different value for every clone and for the other ones the value is shared between clones and the main sprite.

#signature
yes my signature is bigger than this, select a piece of text and use shift+down to scroll through it


I reside at www.npxl32.com, with the www because it won't work otherwise.

















i like Microsoft

(download this and upload it as a sprite to scratch): https://backpack.scratch.mit.edu/f1eceb3e927259af33ebc9ec27d72d6b.zip
mstone326
Scratcher
1000+ posts

Minimum requirements for a "for this sprite only" variable to be accessed by clones

The for all sprites (global) variables everyone in the project can see. For this sprite only (local) variables are only seen by that sprite or clones of that sprite who the variable was made for.

High School Athletic Director / Middle School Tech Teacher / High School Baseball Coach
Kung Fu by Nintendo 1984 - https://scratch.mit.edu/projects/369994801/
Taco Defense - Speed Typing - https://scratch.mit.edu/projects/316795450/
Halloween Boss Battle - Taking Back our Woods - https://scratch.mit.edu/projects/257155118/
Almost Pong - https://scratch.mit.edu/projects/656276979/
Studio - My Best Projects - https://scratch.mit.edu/studios/4125978/
Forum Help Project Examples - https://scratch.mit.edu/studios/4133335
Yusei-Fudo
Scratcher
1000+ posts

Minimum requirements for a "for this sprite only" variable to be accessed by clones

Yoshiii999 wrote:

Yusei-Fudo wrote:

Can you explain a little more about what you mean?
Like for some for-this-sprite-only variables, there is a different value for every clone and for the other ones the value is shared between clones and the main sprite.

Not quite, though, there is a very neat work around. Hope you are good with lists.

It's a bit more complicated, but will get you the exact result you want.
First, create a new list for all sprites:


Next, create a new variable called “clone #” for this sprite only:


Then, when you create a clone, just set “clone #” to a certain value.
So, if you want to increase the value as you create clones (hope you get what this sentence means), just do something like this:


Now, let's say that you want to store a clone's x (1 data set) and y position (2 data sets), you would get their positions from the list like this (there's another easier way, but this one is the mathematical way):
(item ((which clone's datas you want to get::grey)*(number of data sets, in this case, 2::grey)) of [list v] :: list)// This is the FIRST step.
//The previous script gives you the first data from the entire data set that belongs to that clone.
(item (((which clone's datas you want to get::grey)*(number of data sets, in this case, 2::grey))+(a number between 1 and the number of data sets::grey)) of [list v] :: list)
//That was the last step, and you're done if you've followed everything correctly.

Hope this helps. Let me know if you have any questions, this is a little confusing.

Last edited by Yusei-Fudo (July 17, 2021 03:48:55)


I'm a decent coder who has a huge passion for coding. I taught myself all the coding skills I have now. And with those skills, I have made some pretty decent projects, check them out! Be sure to ⭐ ❤️ & Follow, too! I have a few pictures below which are actually links. Click on them to take to different projects that I made. Might come in handy. :)

Need a project where you can check to see if you can use someone's camera or not? Here's one:


Need a project to detect when someone has clicked the stop sign? Take a look at this:

Need a project that can point at specific clones, etc? Why not use this:


Need to prank someone? Tell them to click this picture, but also make sure they're signed onto Scratch, otherwise, it doesn't work:


For more of my projects, just click on this picture:
Yoshiii999
Scratcher
100+ posts

Minimum requirements for a "for this sprite only" variable to be accessed by clones

Yusei-Fudo wrote:

Yoshiii999 wrote:

Yusei-Fudo wrote:

Can you explain a little more about what you mean?
Like for some for-this-sprite-only variables, there is a different value for every clone and for the other ones the value is shared between clones and the main sprite.

Not quite, though, there is a very neat work around. Hope you are good with lists.

It's a bit more complicated, but will get you the exact result you want.
First, create a new list for all sprites:


Next, create a new variable called “clone #” for this sprite only:


Then, when you create a clone, just set “clone #” to a certain value.
So, if you want to increase the value as you create clones (hope you get what this sentence means), just do something like this:


Now, let's say that you want to store a clone's x (1 data set) and y position (2 data sets), you would get their positions from the list like this (there's another easier way, but this one is the mathematical way):
(item ((which clone's datas you want to get::grey)*(number of data sets, in this case, 2::grey)) of [list v] :: list)// This is the FIRST step.
//The previous script gives you the first data from the entire data set that belongs to that clone.
(item (((which clone's datas you want to get::grey)*(number of data sets, in this case, 2::grey))+(a number between 1 and the number of data sets::grey)) of [list v] :: list)
//That was the last step, and you're done if you've followed everything correctly.

Hope this helps. Let me know if you have any questions, this is a little confusing.
Well I know about that, but sometimes every clone has a different value in “for this sprite only” and other times the main value from the main sprite can be accessed and modified by clones. I don't want to work-around it, I want to use the requirements for the main value to be accessed by clones.

#signature
yes my signature is bigger than this, select a piece of text and use shift+down to scroll through it


I reside at www.npxl32.com, with the www because it won't work otherwise.

















i like Microsoft

(download this and upload it as a sprite to scratch): https://backpack.scratch.mit.edu/f1eceb3e927259af33ebc9ec27d72d6b.zip
Yoshiii999
Scratcher
100+ posts

Minimum requirements for a "for this sprite only" variable to be accessed by clones

I'm trying to make a project where it's only clones.
I have experience in using clones dynamically.

#signature
yes my signature is bigger than this, select a piece of text and use shift+down to scroll through it


I reside at www.npxl32.com, with the www because it won't work otherwise.

















i like Microsoft

(download this and upload it as a sprite to scratch): https://backpack.scratch.mit.edu/f1eceb3e927259af33ebc9ec27d72d6b.zip
Yusei-Fudo
Scratcher
1000+ posts

Minimum requirements for a "for this sprite only" variable to be accessed by clones

Yoshiii999 wrote:

Well I know about that, but sometimes every clone has a different value in “for this sprite only” and other times the main value from the main sprite can be accessed and modified by clones. I don't want to work-around it, I want to use the requirements for the main value to be accessed by clones.

I'm confused

I'm a decent coder who has a huge passion for coding. I taught myself all the coding skills I have now. And with those skills, I have made some pretty decent projects, check them out! Be sure to ⭐ ❤️ & Follow, too! I have a few pictures below which are actually links. Click on them to take to different projects that I made. Might come in handy. :)

Need a project where you can check to see if you can use someone's camera or not? Here's one:


Need a project to detect when someone has clicked the stop sign? Take a look at this:

Need a project that can point at specific clones, etc? Why not use this:


Need to prank someone? Tell them to click this picture, but also make sure they're signed onto Scratch, otherwise, it doesn't work:


For more of my projects, just click on this picture:
mstone326
Scratcher
1000+ posts

Minimum requirements for a "for this sprite only" variable to be accessed by clones

I am also confused. Maybe sharing the project so we can see what you are trying to accomplish can help with the confusion.

High School Athletic Director / Middle School Tech Teacher / High School Baseball Coach
Kung Fu by Nintendo 1984 - https://scratch.mit.edu/projects/369994801/
Taco Defense - Speed Typing - https://scratch.mit.edu/projects/316795450/
Halloween Boss Battle - Taking Back our Woods - https://scratch.mit.edu/projects/257155118/
Almost Pong - https://scratch.mit.edu/projects/656276979/
Studio - My Best Projects - https://scratch.mit.edu/studios/4125978/
Forum Help Project Examples - https://scratch.mit.edu/studios/4133335
theanonymousweirdo
Scratcher
500+ posts

Minimum requirements for a "for this sprite only" variable to be accessed by clones

Use the block right under the reset timer block in sensing
([variable v] of [Sprite1 v])

This is my signature. It appears at the bottom of all of my posts.
My favorite song: You're Not Alone

Powered by DjangoBB