Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Is there a workaround for "For this sprite only" Variables? / Is there a way for a sprite to read the local Variable of a clone it is touching?
- meh_dog
-
Scratcher
4 posts
Is there a workaround for "For this sprite only" Variables? / Is there a way for a sprite to read the local Variable of a clone it is touching?
I'm making a maze game where the maze and the goal are the same sprite, and are both clones.I use a local variable to tell the difference between the two. (Aka a ID variable)
The player movement script prevents movement if you try to move through the walls, but i can't find a way for the player character's script to be able to read the ID of the clone it is touching. So it can't tell the difference between the wall and the goal.
Is there a way for the player character to read the ID of a clone it is touching?
The player movement script prevents movement if you try to move through the walls, but i can't find a way for the player character's script to be able to read the ID of the clone it is touching. So it can't tell the difference between the wall and the goal.
Is there a way for the player character to read the ID of a clone it is touching?
Last edited by meh_dog (March 8, 2023 20:15:03)
- Sniffles_Rule
-
Scratcher
42 posts
Is there a workaround for "For this sprite only" Variables? / Is there a way for a sprite to read the local Variable of a clone it is touching?
An easy way to do this would be
Or you have them be different sprites and the player just detects what sprite it is touching
<touching color [#c2ee55] ?>And then having the walls and the goal be different colours
Or you have them be different sprites and the player just detects what sprite it is touching
- rgite
-
Scratcher
42 posts
Is there a workaround for "For this sprite only" Variables? / Is there a way for a sprite to read the local Variable of a clone it is touching?
I found an extend to it and helped you kinda.
You could edit it! Your welcome!

if <touching color [#ab484f] ?> then
stop [ v]
end
You could edit it! Your welcome!

- bmitchem
-
Scratcher
2 posts
Is there a workaround for "For this sprite only" Variables? / Is there a way for a sprite to read the local Variable of a clone it is touching?
Following up to the previous, you could also use
As a variable. So it would read something like
When I'm a clone
Loop-
If touching player and Costume = Goal
Then say “you win”
(costume #)
As a variable. So it would read something like
When I'm a clone
Loop-
If touching player and Costume = Goal
Then say “you win”
- 10data10
-
Scratcher
100+ posts
Is there a workaround for "For this sprite only" Variables? / Is there a way for a sprite to read the local Variable of a clone it is touching?
Is there a way for the player character to read the ID of a clone it is touching?
This would do it but it does not exist
create clone of [Wall v] named [Goal] :: control
And then in the Player sprite you could use
if <touching (join [Goal] []) ?> thensorry
end
You Can, however, turn it around have have the Goal clone do a touching test to see if it is touching the Player sprite and, if true, set a variable or make a broadcast. I’m guessing that you don’t want to just make a Goal Sprite because you might want to have one or more possible goals.
- legendary34678
-
Scratcher
1000+ posts
Is there a workaround for "For this sprite only" Variables? / Is there a way for a sprite to read the local Variable of a clone it is touching?
For the player sprite to read the ID of a clone it is touching, the clone could either set a global (For all sprites) variable to its ID or add its ID to a global (For all sprites) list that the player sprite can access.
- theflyingmence
-
Scratcher
73 posts
Is there a workaround for "For this sprite only" Variables? / Is there a way for a sprite to read the local Variable of a clone it is touching?
make it so that the clone sets a different variable to its id when touching player
- Discussion Forums
- » Help with Scripts
-
» Is there a workaround for "For this sprite only" Variables? / Is there a way for a sprite to read the local Variable of a clone it is touching?