Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » i need help getting coordinates from a string of digits.
- Hboy0805
-
Scratcher
21 posts
i need help getting coordinates from a string of digits.
I need to somehow get coordinates from a string of values.
Here's a demo, it's just for a level editor system you can save and load.
https://scratch.mit.edu/projects/967693084/
im giving the link so you can see the code.
Here's a demo, it's just for a level editor system you can save and load.
https://scratch.mit.edu/projects/967693084/
im giving the link so you can see the code.
- bombardingppl
-
Scratcher
500+ posts
i need help getting coordinates from a string of digits.
I'm not sure if I understand exactly, but I think you would just want to make two separate lists for y and x, which would be easier, but if you for some reason have to have it in one list, you could just join each digit to a variable until you get a space add that to wherever you need it, and repeat this again for the y like this:
I'm pretty sure this would work but if it doesn't you can ask me again here
set [coordinates index] to [1]
set [x] to [] //blank
set [y] to []
repeat until <(letter (coordinates index) of (string)) = [ ]> //the blank is a space
set [x] to (join (x) (letter (coordinates index) of (string))
change [coordinates index] by [1]
end
change [coordinates index] by [1]
repeat until <(letter (coordinates index) of (string)) = [ ]>
set [y] to (join (y) (letter (coordinates index) of (string))
change [coordinates index] by [1]
end
I'm pretty sure this would work but if it doesn't you can ask me again here
- Hboy0805
-
Scratcher
21 posts
i need help getting coordinates from a string of digits.
it works.. Only for the x, the y is just blank, and i want it to be able to get one position down and move to the next and stuff like that, i've attempted to troubleshoot, but it hasn't done me very well so far..
- bombardingppl
-
Scratcher
500+ posts
i need help getting coordinates from a string of digits.
have you tried my first solution of just using two lists for the x and y? Otherwise I don't have a good idea… Try to figure it out though, I'll try as well.
- Hboy0805
-
Scratcher
21 posts
i need help getting coordinates from a string of digits.
yes i did! i had to make a new system to work with them though which was tough, but yes, i did.
- deck26
-
Scratcher
1000+ posts
i need help getting coordinates from a string of digits.
There are two simple tricks which would allow you to use a single list if you preferred.
1 - put the x value in one item and the y value in the next item so all items are n pairs
2 - add 400 to x and y so you know each is a 3 digit number so you can join to get a 6 digit string. More work to split these again but a useful method if writing to cloud variables and using one variable for multiple values.
1 - put the x value in one item and the y value in the next item so all items are n pairs
2 - add 400 to x and y so you know each is a 3 digit number so you can join to get a 6 digit string. More work to split these again but a useful method if writing to cloud variables and using one variable for multiple values.
- Hboy0805
-
Scratcher
21 posts
i need help getting coordinates from a string of digits.
alright, i'll try that!
- Discussion Forums
- » Help with Scripts
-
» i need help getting coordinates from a string of digits.


