Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How can I set X and Y position of a variable?
- Scratch739201
-
500+ posts
How can I set X and Y position of a variable?
How can I set X and Y position of a variable? Or let the variable gilde or move?
I wish there's a block like this:
I wish there's a block like this:
set x: (100) y:(-25) for [my-var v] :: variables
let [my-var v] glide to x: (25) y: (-55) :: variables
- Thejbomber
-
100+ posts
How can I set X and Y position of a variable?
You can't; you can click and drag it to a spot. To create the illusion of it, you can create a small sprite, like a black dot, set it to, say, 0,0, and just put the variable over it. No, you cannot move a variable by a block.
- Scratch739201
-
500+ posts
How can I set X and Y position of a variable?
To create the illusion of it, you can create a small sprite, like a black dot, set it to, say, 0,0, and just put the variable over it.
What should the black dot do??? I don't know why a black dot should do anything with a variable. Can you please explain why?
- Thejbomber
-
100+ posts
How can I set X and Y position of a variable?
You put the variable expression (the box with a number) over the black dot. That way, you can tell exactly where the variable is.
- Scratch739201
-
500+ posts
How can I set X and Y position of a variable?
liKe a marKer right?
- Dinosaur_Weirdo
-
12 posts
How can I set X and Y position of a variable?
Yes, I would love this. For an online multiplayer thing with something like…
(being a button for player 1)
However, due to limitations of cloud variables, we would not be able to set a variable to a username unless the username contained only numbers, which is unlikely.
Darn.
But the concept is still cool, right?
Also, setting the view of the variable (large readout, normal readout or slider) with something like
Support.
(being a button for player 1)
when this sprite clicked(being a sprite that moves with certain keys, eg player 1)
set [player selected] to [1]
when green flag clicked
forever
if <(player selected) = [1]>
set [☁ player 1 username] to (username)
show variable [☁ player 1 username]
stop [this script]
when green flag clicked…would be great for having a username underneath a sprite.
forever
set [☁ p1x] to (x position)
set [☁ p2x] to (y position)
set x of [☁ player 1 username] to (☁ p1x)
set y of [☁ player 1 username] to <(☁ p1y) - [5]>
However, due to limitations of cloud variables, we would not be able to set a variable to a username unless the username contained only numbers, which is unlikely.
Darn.
But the concept is still cool, right?
Also, setting the view of the variable (large readout, normal readout or slider) with something like
when green flag clickedwould be pretty nice.
set type for [☁ player 1 username] to [small]
Support.
- deck26
-
1000+ posts
How can I set X and Y position of a variable?
Every cloud list project encodes and decodes usernames so they can be stored in cloud variables. Yes, I would love this. For an online multiplayer thing with something like…
(being a button for player 1)when this sprite clicked(being a sprite that moves with certain keys, eg player 1)
set [player selected] to [1]when green flag clicked
forever
if <(player selected) = [1]>
set [☁ player 1 username] to (username)
show variable [☁ player 1 username]
stop [this script]when green flag clicked…would be great for having a username underneath a sprite.
forever
set [☁ p1x] to (x position)
set [☁ p2x] to (y position)
set x of [☁ player 1 username] to (☁ p1x)
set y of [☁ player 1 username] to <(☁ p1y) - [5]>
However, due to limitations of cloud variables, we would not be able to set a variable to a username unless the username contained only numbers, which is unlikely.
Darn.
But the concept is still cool, right?
Also, setting the view of the variable (large readout, normal readout or slider) with something likewhen green flag clickedwould be pretty nice.
set type for [☁ player 1 username] to [small]
Support.
- Dinosaur_Weirdo
-
12 posts
How can I set X and Y position of a variable?
This is true, but I myself am still fairly new to Scratch and although I have looked at them, I have not been able to figure them out.Every cloud list project encodes and decodes usernames so they can be stored in cloud variables. Yes, I would love this. For an online multiplayer thing with something like…
(being a button for player 1)when this sprite clicked(being a sprite that moves with certain keys, eg player 1)
set [player selected] to [1]when green flag clicked
forever
if <(player selected) = [1]>
set [☁ player 1 username] to (username)
show variable [☁ player 1 username]
stop [this script]when green flag clicked…would be great for having a username underneath a sprite.
forever
set [☁ p1x] to (x position)
set [☁ p2x] to (y position)
set x of [☁ player 1 username] to (☁ p1x)
set y of [☁ player 1 username] to <(☁ p1y) - [5]>
However, due to limitations of cloud variables, we would not be able to set a variable to a username unless the username contained only numbers, which is unlikely.
Darn.
But the concept is still cool, right?
Also, setting the view of the variable (large readout, normal readout or slider) with something likewhen green flag clickedwould be pretty nice.
set type for [☁ player 1 username] to [small]
Support.
Any help on this would be greatly appreciated.
Thanks!
- MrFluffyPenguins
-
1000+ posts
How can I set X and Y position of a variable?
Derp
Last edited by MrFluffyPenguins (Aug. 3, 2017 18:59:03)
- TheCookieHero880
-
100+ posts
How can I set X and Y position of a variable?
Use a text engine
https://scratch.mit.edu/projects/66904754/
They look cooler too
I agree, you should use a text engine, sprites which write out variable texts. It allowes for moving of variables as well as much more customisation.
- Ayarkay
-
73 posts
How can I set X and Y position of a variable?
Well a variable simply stores a number, and a number doesn't have an x or a y value. It only has one value, which is that number's value.
If you wanted to use variables to represent coordinates, you'd need to have 2 separate variables, representing x and y respectively.
As far as making things glide goes, when you think about it, when an object glides from point A to point B, what happens is that A's x value slides to B's x value, and A's y value slides to B's y value. In order to glide from one value to another, we need to be able to create a system which takes in a starting number, and ending number, and the number of steps you want it to take before it reaches the ending number (the glide speed).
So:
Let a = the starting number
Let b = the ending number
Let t = the glide time
So we want to glide from a -> b in t amount of time.
( |(a-b)| / t ) * x + a
Here, if you input a, b, and t, you can iterate x all the way up to t in order to interpolate its value at all points between 0 and t.
So if you wanted to glide between 2 xy coordinates, you'd run the above formula for the x-values and the y-values separately, but have the glide time be the same for both.
If you wanted to use variables to represent coordinates, you'd need to have 2 separate variables, representing x and y respectively.
As far as making things glide goes, when you think about it, when an object glides from point A to point B, what happens is that A's x value slides to B's x value, and A's y value slides to B's y value. In order to glide from one value to another, we need to be able to create a system which takes in a starting number, and ending number, and the number of steps you want it to take before it reaches the ending number (the glide speed).
So:
Let a = the starting number
Let b = the ending number
Let t = the glide time
So we want to glide from a -> b in t amount of time.
( |(a-b)| / t ) * x + a
Here, if you input a, b, and t, you can iterate x all the way up to t in order to interpolate its value at all points between 0 and t.
So if you wanted to glide between 2 xy coordinates, you'd run the above formula for the x-values and the y-values separately, but have the glide time be the same for both.
Last edited by Ayarkay (Aug. 3, 2017 20:33:45)
- TheKingRafael
-
41 posts
How can I set X and Y position of a variable?
Well a variable simply stores a number, and a number doesn't have an x or a y value. It only has one value, which is that number's value.
If you wanted to use variables to represent coordinates, you'd need to have 2 separate variables, representing x and y respectively.
As far as making things glide goes, when you think about it, when an object glides from point A to point B, what happens is that A's x value slides to B's x value, and A's y value slides to B's y value. In order to glide from one value to another, we need to be able to create a system which takes in a starting number, and ending number, and the number of steps you want it to take before it reaches the ending number (the glide speed).
So:
Let a = the starting number
Let b = the ending number
Let t = the glide time
So we want to glide from a -> b in t amount of time.
( |(a-b)| / t ) * x + a
Here, if you input a, b, and t, you can iterate x all the way up to t in order to interpolate its value at all points between 0 and t.
So if you wanted to glide between 2 xy coordinates, you'd run the above formula for the x-values and the y-values separately, but have the glide time be the same for both.
Well.. That must be awesome, but this guy was talking about moving the “casing” of a variable showing its value ingame.
————————————————————————————————————————————————————————————————-
Personally, I always use number sprites to show the value of the variable where-ever I want. It's easy to move around and it looks better. The disadvantage is that it's a little harder to make, but Scratch is made to learn from, so this is a nice opportunity to do so, I think!

- SuperCDI
-
1 post
How can I set X and Y position of a variable?
So you know the scrolling type variable I wondered if you can make a sprite move from that variable! Please reply 

- Uniquename1
-
100+ posts
How can I set X and Y position of a variable?
Didn't read all the other stuff you can make a little dot move it about and use the
say (foo)blocks.
- RLCAnika19
-
1 post
How can I set X and Y position of a variable?
do you need a background that you made, or can you use one that scratch made to find the x and y coordinates? plz help, because I need it for a project!
check out my games!
flying kitty cat maze
Get The Puppy Home!!!! the one with the green background, and has black and blue.
the story of how Voldemort got moldy!!! A Harry Potter story
The Gray and Blue. A civil war Question and Answer thing.
check out my games!
flying kitty cat maze
Get The Puppy Home!!!! the one with the green background, and has black and blue.
the story of how Voldemort got moldy!!! A Harry Potter story
The Gray and Blue. A civil war Question and Answer thing.

- codeman1044
-
1000+ posts
How can I set X and Y position of a variable?
Please don't necropost. This topic's last post is from 2017.
- _MasterIsCool_
-
4 posts
How can I set X and Y position of a variable?
I am typing years later!
- FoofJr
-
100+ posts
How can I set X and Y position of a variable?
I am typing years later!PLEASE do not necropost. Bringing up an old topic just to announce something is very irritating, and does not help anyone in anyway. All it does is bring dup a resolved topic to the top of the forums.
- Discussion Forums
- » Help with Scripts
-
» How can I set X and Y position of a variable?