Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Letters to numbers
- AntriFeint
-
Scratcher
1 post
Letters to numbers
Ok so like how should i code something that turns letters to numbers (to work in cloud variables)
Like if you have some text “hi” it gets turned into “01064” and can be decoded later
How should i do that?
Like if you have some text “hi” it gets turned into “01064” and can be decoded later
How should i do that?
- Cat_Dusty
-
Scratcher
500+ posts
Letters to numbers
Here's a good article on the Scratch Wiki
https://en.scratch-wiki.info/wiki/Encoding/Decoding_Data
https://en.scratch-wiki.info/wiki/Encoding/Decoding_Data
- SansStudios
-
Scratcher
1000+ posts
Letters to numbers
Welcome to the forums!
To do this yourself, you want to have some way to convert letters to numbers. One way of doing this would be through a conversion where you make each letter equal one number. For example:
a = 10,
b = 11,
c = 12,
and so on.
Then, when you want to encode, you just translate everything: abc => 101112
And when you decode, you do the opposite: 1010101211 => aaacb
Alternatively, you could use someone else's code. Here's my encoder:
https://scratch.mit.edu/projects/622026587/editor/
Hope this helps! If you have more questions, let me know
To do this yourself, you want to have some way to convert letters to numbers. One way of doing this would be through a conversion where you make each letter equal one number. For example:
a = 10,
b = 11,
c = 12,
and so on.
Then, when you want to encode, you just translate everything: abc => 101112
And when you decode, you do the opposite: 1010101211 => aaacb
Alternatively, you could use someone else's code. Here's my encoder:
https://scratch.mit.edu/projects/622026587/editor/
Hope this helps! If you have more questions, let me know

- BombyGomby9
-
Scratcher
68 posts
Letters to numbers
actually what i think from letters to numbers is making the letter by alphabet number, for example e will be 5 and a will be 1, meaning the maximum letters will be 26 according to google, and to actually tell a number by the first number, the alphabet would be 01, for example,
a is 01
b is 02
c is 03
d is 04
e is 05
f is 06
and to tell capital letters, we will need 52 numbers, for example, i encoded my name to 28151302253315130225
so we will add 0009
281513022533151302250009, for decoded it's BombyGomby9, i still watch griffpatch and i still use this method, for example “hi” is 0809, making a symbols soon
btw special script
a is 01
b is 02
c is 03
d is 04
e is 05
f is 06
and to tell capital letters, we will need 52 numbers, for example, i encoded my name to 28151302253315130225
so we will add 0009
281513022533151302250009, for decoded it's BombyGomby9, i still watch griffpatch and i still use this method, for example “hi” is 0809, making a symbols soon
btw special script
define lose life
set [lives v] to (lives) - (1)
- -Krios-
-
Scratcher
96 posts
Letters to numbers
- Make a list that includes all of the characters you want to use (leave the first nine blank, so they're all double digits).
- to get the number of a character, use the list block
(item # of () of [list v] :: list)
(replace the blank with the character). - To do the opposite (get the letter from the number), use this block:
(item ( ) of [list v] :: list)
(again, replace the blank with the number.)
Alternatively, you could use the “Cloud blocks” from This project (they're in a sprite) to change from the number format to the text format (it says cloud format, but it's the same as what we're doing here)
- Discussion Forums
- » Help with Scripts
-
» Letters to numbers