Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Independet Clone Variables
- gallerdude
-
Scratcher
1 post
Independet Clone Variables
I don't really know how to explain this, but I'll try.
Is there a way to make clones have variables specific to each individual clone?
For example, let's say I have a game that randomly creates monsters with 3 health each.
Each monster would keep track of it's health independently.
Is there a way to do this without the monster's occupying pre-made variables?
I know i can set it so that each monster can “occupy” a health variable, but I'm wondering if there's another way.
Is there a way to make clones have variables specific to each individual clone?
For example, let's say I have a game that randomly creates monsters with 3 health each.
Each monster would keep track of it's health independently.
Is there a way to do this without the monster's occupying pre-made variables?
I know i can set it so that each monster can “occupy” a health variable, but I'm wondering if there's another way.
- SuperJedi224
-
Scratcher
100+ posts
Independet Clone Variables
I don't really know how to explain this, but I'll try.“this sprite only” variables apply separately to each instance.
Is there a way to make clones have variables specific to each individual clone?
For example, let's say I have a game that randomly creates monsters with 3 health each.
Each monster would keep track of it's health independently.
Is there a way to do this without the monster's occupying pre-made variables?
I know i can set it so that each monster can “occupy” a health variable, but I'm wondering if there's another way.
- bob6
-
Scratcher
100+ posts
Independet Clone Variables
Sorry for reviving this thread, but I have the same problem. I have multiple clones of one sprite, but how can I get it so that each clone has its own set of variables? The above user shows how to have separate variables for each sprite, but I want to know how to do separate variables for each clone.
- scubajerry
-
Scratcher
1000+ posts
Independet Clone Variables
The for THIS SPRITE ONLY should really be named for THIS SPRITE OR THIS CLONE ONLY.
It gives a variable just for this sprite.
Here is a simple example. http://scratch.mit.edu/projects/13856686/#player
It gives a variable just for this sprite.
Here is a simple example. http://scratch.mit.edu/projects/13856686/#player
- cwrivera99
-
Scratcher
500+ posts
Independet Clone Variables
Yeah. whenever you make a clone of that sprite, any variables that are independent for that sprite are cloned as well, and whatever the clone sets the variable to will not affect the value of other clones or the original sprite.
- leahjosh
-
Scratcher
25 posts
Independet Clone Variables
I don't really know how to explain this, but I'll try.you could use a list as in
Is there a way to make clones have variables specific to each individual clone?
For example, let's say I have a game that randomly creates monsters with 3 health each.
Each monster would keep track of it's health independently.
Is there a way to do this without the monster's occupying pre-made variables?
I know i can set it so that each monster can “occupy” a health variable, but I'm wondering if there's another way.
when I receive [ blah blah blah v]
set [ var counter v] to [0]
repeat (3)
change [ var counter v] by (1)
add (join (join [sprite ] ( var counter )) [ health]) to [list la la la v]
end
- leahjosh
-
Scratcher
25 posts
Independet Clone Variables
once you have done this then you have 3 seperate list items that can represent variablesI don't really know how to explain this, but I'll try.you could use a list as in
Is there a way to make clones have variables specific to each individual clone?
For example, let's say I have a game that randomly creates monsters with 3 health each.
Each monster would keep track of it's health independently.
Is there a way to do this without the monster's occupying pre-made variables?
I know i can set it so that each monster can “occupy” a health variable, but I'm wondering if there's another way.when I receive [ blah blah blah v]
set [ var counter v] to [0]
repeat (3)
change [ var counter v] by (1)
add (join (join [sprite ] ( var counter )) [ health]) to [list la la la v]
end
- leahjosh
-
Scratcher
25 posts
Independet Clone Variables
OK I have a project with multiple possibly useful blocks I have made here: http://scratch.mit.edu/projects/46095980/
- f_deruvo
-
Scratcher
100+ posts
Independet Clone Variables
Hi all,
I insert here my question about clone sprite_name.
Question:
when I use sprite, I use a sensing block to get variable value of another sprite
indicating the sprite name I can acces local variable.
How can I do the same with clone ? which name I have to give?
Thanks very much
I insert here my question about clone sprite_name.
Question:
when I use sprite, I use a sensing block to get variable value of another sprite
([ v] of [ v])
indicating the sprite name I can acces local variable.
How can I do the same with clone ? which name I have to give?
Thanks very much
- deck26
-
Scratcher
1000+ posts
Independet Clone Variables
Hi all,You've created your own topic on this so I suggest people ignore this one and let this topic go back to sleep.
I insert here my question about clone sprite_name.
Question:
when I use sprite, I use a sensing block to get variable value of another sprite([ v] of [ v])
indicating the sprite name I can acces local variable.
How can I do the same with clone ? which name I have to give?
Thanks very much
- coolguy135ty
-
Scratcher
100+ posts
Independet Clone Variables
Hi, I have a similar problem, except i want a sprite to go to one clone, and the other sprite to go to another, is this possible? I already tried lists btw, it only does one clone a a time.

go to x: (item (1 v) of [clones v]) y:(item (last v) of [ clones v]) (0)

- tdRaiders
-
Scratcher
20 posts
Independet Clone Variables
I have the same problem too. I want clones that have health and their health would go down if hit by different enemies. All I can come up with is naming the clones. Any idea on how to do that????????
when I receive [ the answer]
you will be [ mentioned] in my game credits
- footsocktoe
-
Scratcher
1000+ posts
Independet Clone Variables
I have the same problem too. I want clones that have health and their health would go down if hit by different enemies. All I can come up with is naming the clones. Any idea on how to do that????????when I receive [ the answer]
you will be [ mentioned] in my game credits
Yes. Look at this example…
https://scratch.mit.edu/projects/113617031/
- baboom1
-
Scratcher
15 posts
Independet Clone Variables
there is such a variable, its called a lexically scoped variable, make it a local variable to make it calculate them individually
- dacoo12
-
Scratcher
2 posts
Independet Clone Variables
Hello everybody, I'm having trouble with getting different clones to go to different speeds for a cannon shooting game.
I thought maybe this would work:
and then this:
I thought maybe this would work:
when green flag clicked
set [clone id] to [0]
repeat until <mouse down?>
calculate stuff
end
add (join (gravity) (launch speed)) to [clone settings]
create clone of [cannonball]
wait until <not <mouse down?>>
and then this:
when I start as a clone
change [clone id] by (1)
repeat until <touching color [#ff0000] ?>
move (launchspeed) steps
apply gravity
end
delete this clone
- asivi
-
Scratcher
1000+ posts
Independet Clone Variables
I think it was responded above, make all of those variables as “for this sprite only” when ceated.
- Harakou
-
Scratcher
1000+ posts
Independet Clone Variables
I think it was responded above, make all of those variables as “for this sprite only” when ceated.Seems like it was. Given the age of this thread, it might be best to ask in a new thread if you have any other related questions - that way people will know which question is still unanswered.

- Discussion Forums
- » Help with Scripts
-
» Independet Clone Variables

