Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Save codes
- funman37
-
35 posts
Save codes
I've made a project where you can customize a suit of armor from the videogame franchise Halo. I'm trying to implement a save code system so that people can share their designs or view them at a later time. Currently the code is along the lines of He0Ha0Tt0Ca0St0SpL0SpR0Ta0Kn0Sh0Wa0, with each 2 letter abbreviation representing a different component of the armor, and the number after it being which variation it is (He2 would be the second helmet, Ha3 would be the third helmet attachment, etc. etc.). I've got a line of code that works perfectly as long as the number is only one digit, but most numbers go into the double digits. Is there any way to make it read multiple numbers based on whether they're there or not? (Reads only 2 if only one number is there but reads 23 if the second number exists)
Last edited by funman37 (June 21, 2023 16:02:56)
- scratchcode1_2_3
-
1000+ posts
Save codes
Yes there is, kind of! If you want to keep it simple you wouldn't want to detect if they're there or not. But that also means that just like dates, if it is a single number, you have to add a 0 first. So if you want 3, you would have to make the code say 03. Here is how to save 2-digit numbers from a code:
I can't see your code, so I can't do much, but I hope that helps!
... // keep in mind that this piece of code is inside your loop that reads the code
set (helmetNumber) to (join (letter (i) of (code)) (letter ((i) + [1]) of (code))) // where i means iteration
change (i) by [2] // so it doesn't read the same number again
...
I can't see your code, so I can't do much, but I hope that helps!

- PhiPhenomenon
-
500+ posts
Save codes
This is the code I've created for your issue:

It works for digits of all sizes and reads the individual weapons/armor into the components list.

It works for digits of all sizes and reads the individual weapons/armor into the components list.
- funman37
-
35 posts
Save codes
Yes there is, kind of! If you want to keep it simple you wouldn't want to detect if they're there or not. But that also means that just like dates, if it is a single number, you have to add a 0 first. So if you want 3, you would have to make the code say 03. Here is how to save 2-digit numbers from a code:... // keep in mind that this piece of code is inside your loop that reads the code
set (helmetNumber) to (join (letter (i) of (code)) (letter ((i) + [1]) of (code))) // where i means iteration
change (i) by [2] // so it doesn't read the same number again
...
I can't see your code, so I can't do much, but I hope that helps!
The script works for multi-digit numbers, but I'm not sure how to make it recognize if it's a single-digit number and needs to add a zero or not. Making a script that says
if <[9] < (Helmet)> thenJust adds “0” to the start of the variable repeatedly.
else
set [Helmet] to (join [0] (Helmet))
end
Last edited by funman37 (June 21, 2023 19:11:19)
- pikachuLuke5
-
100+ posts
Save codes
when this sprite clicked
change [Clicks v] by (CPC)
when green flag clicked
set [Clicks v] to [0]
set [CPC v] to [1]
- scratchcode1_2_3
-
1000+ posts
Save codes
(#5)uhhh did you click on the wrong topic? This is something else about the save codes.
-snip-
- Discussion Forums
- » Help with Scripts
-
» Save codes