Discuss Scratch
- Discussion Forums
- » Questions about Scratch
- » Help on scripts
- WabbaHarry
-
11 posts
Help on scripts
Hey I was trying to make an Export/Import save function to my newest project so people could walk away enter a code and resume from where they left off. However I was wondering how to detect certain characters in an answer. Basically the code will go | |….
Now I was wondering how I could detect those lines in-between as some of the numbers could be longer or shorter than I expect.
Basically my project is Cookie Clicker and you have CpS, Cookies, Cursors, Grandmas. That is the order of the numbers. The CpS could have a decimal point and the Cookies could end up being really big. Using these lines separates the numbers but I need to detect them to set the numbers to these when they start. Thanks for any help!
-WabbaHarry
Now I was wondering how I could detect those lines in-between as some of the numbers could be longer or shorter than I expect.
Basically my project is Cookie Clicker and you have CpS, Cookies, Cursors, Grandmas. That is the order of the numbers. The CpS could have a decimal point and the Cookies could end up being really big. Using these lines separates the numbers but I need to detect them to set the numbers to these when they start. Thanks for any help!
-WabbaHarry
- turkey3
-
1000+ posts
Help on scripts
So you're trying to detect specific characters within a string item? To check if it contains those two lines, try the following code:
set [letter# v] to (1)Any further help needed I will do
set [detected | v] to (0)
repeat (length of (answer))
if <(letter (letter#) of (answer)) = [|]> //if a straight slash is detected
change [detected | v] by (1)
end
change [letter# v] by (1)
end
if <(detected |) > (1)> //if two | are detected
use the numbers

- Discussion Forums
- » Questions about Scratch
-
» Help on scripts