Discuss Scratch
- Discussion Forums
- » Questions about Scratch
- » can someone please give me a script that works like this?
- Aaronhoffer
-
Scratcher
100+ posts
can someone please give me a script that works like this?
set (letter (3) of (Var)) to [6 ]
- PrincessPanda_test_
-
Scratcher
1000+ posts
can someone please give me a script that works like this?
Impossible.
Or maybe just complicated. You need to edit the JSON.
Or maybe just complicated. You need to edit the JSON.
Last edited by PrincessPanda_test_ (Oct. 6, 2015 22:38:19)
- DrKat123
-
Scratcher
1000+ posts
can someone please give me a script that works like this?
Impossible.I'm not quite sure about that. Maybe there's a difficult workaround ?
- gdpr533f604550b2f20900645890
-
Scratcher
1000+ posts
can someone please give me a script that works like this?
I think you need change the JSON, but I'm not sure.Impossible.I'm not quite sure about that. Maybe there's a difficult workaround ?
- DrKat123
-
Scratcher
1000+ posts
can someone please give me a script that works like this?
O yeah ! Hacked blocks. But as I say, it's going to be difficult.I think you need change the JSON, but I'm not sure.Impossible.I'm not quite sure about that. Maybe there's a difficult workaround ?
- MelonManatee
-
Scratcher
100+ posts
can someone please give me a script that works like this?
set [variable v] to (join [1] (join [1] (join [6] [1])))
You could do something like that I suppose. Or maybe:
set [variable v] to (join (letter (1) of (variable)) (join (letter (2) of (variable) )(join [6] (letter (4) of (variable))))
So this script I think should be able to join the first, second and fourth letters of the variable (so it doesn't change them) and sets 6 as the third.
Hope I helped!

- CatsUnited
-
Scratcher
1000+ posts
can someone please give me a script that works like this?
You will have to add this script:
set [var v] to [ ]. Then, you need to download the file, extract the sb2 file (it's a disguised zip file), open “project.json” on your text editor and then edit it so the blocks combine without going in the string slot.
(letter (3) of (var)) // this has to be detached
- thebriculator
-
Scratcher
100+ posts
can someone please give me a script that works like this?
https://scratch.mit.edu/projects/80786676/
You can use the blocks in this project by dragging them into your backpack and dragging them into your project.
Be sure that whenever one of these blocks is referenced, the reporter is the name of an existing variable, or you will create a variable on the spot.
You can use the blocks in this project by dragging them into your backpack and dragging them into your project.
Be sure that whenever one of these blocks is referenced, the reporter is the name of an existing variable, or you will create a variable on the spot.
- Prinseskat
-
Scratcher
1000+ posts
can someone please give me a script that works like this?
Do you want to replace the third letter of a variable with 6, or find a variable that's called the third letter of another variable - e.g if the value of Var was abcd, then it'd find a variable called c - and set that to 6?
To replace a letter of a string with something else, you can do this:
Otherwise, if you want to set a variable which is the third letter of another variable to 6, you'll need to hack the JSON code to put
You can do this by downloading the project (or make a new, blank project and backpack it later), unzipping it, and opening the project.json file. Look for something similar to
and replace
with
Rezip the file and rename it something.sb2, then open it in the Scratch editor. It should work.
Or, if you like, I've shared a project with the block: https://scratch.mit.edu/projects/80799944/ You can go inside and put the block into your backpack, then use it in another project.
To replace a letter of a string with something else, you can do this:
define replace letter (n) of (string) with (letter)Which doesn't require JSON hacking.
set [i v] to [1]
set [return v] to []
repeat ((n) - [1])
set [return v] to (join (return) (letter (i) of (string)))
change [i v] by [1]
end
set [return v] to (join (return) (letter))
change [i v] by [1]
repeat ((length of (string)) - (n))
set [return v] to (join (return) (letter (i) of (string)))
change [i v] by [1]
end
//For your example, it could be used like this:
replace letter [3] of (Var) with [6]
set [Var v] to (return)
Otherwise, if you want to set a variable which is the third letter of another variable to 6, you'll need to hack the JSON code to put
(letter (3) of (Var))in the variable dropdown in
set [ v] to [6]which isn't possible in “normal” Scratch.
You can do this by downloading the project (or make a new, blank project and backpack it later), unzipping it, and opening the project.json file. Look for something similar to
"scripts": [[10, 10, [["letter:of:", 3, "string"]]],
[10, 40, [["setVar:to:", "variable", 0]]]],
[10, 40, [["setVar:to:", "variable", 0]]]],
"scripts": [[10, 10, [["letter:of:", 3, "string"]]],
[10, 40, [["setVar:to:", ["letter:of:", 3, "abc"], 0]]]],
Or, if you like, I've shared a project with the block: https://scratch.mit.edu/projects/80799944/ You can go inside and put the block into your backpack, then use it in another project.
Last edited by Prinseskat (Oct. 7, 2015 07:04:03)
- DrKat123
-
Scratcher
1000+ posts
can someone please give me a script that works like this?
Do you want to replace the third letter of a variable with 6, or find a variable that's called the third letter of another variable - e.g if the value of Var was abcd, then it'd find a variable called c - and set that to 6?You sure know about JSON ! So the answer to this question is: it's possible to do it, but it will require hackings
To replace a letter of a string with something else, you can do this:define replace letter (n) of (string) with (letter)Which doesn't require JSON hacking.
set [i v] to [1]
set [return v] to []
repeat ((n) - [1])
set [return v] to (join (return) (letter (i) of (string)))
change [i v] by [1]
end
set [return v] to (join (return) (letter))
change [i v] by [1]
repeat ((length of (string)) - (n))
set [return v] to (join (return) (letter (i) of (string)))
change [i v] by [1]
end
//For your example, it could be used like this:
replace letter [3] of (Var) with [6]
set [Var v] to (return)
Otherwise, if you want to set a variable which is the third letter of another variable to 6, you'll need to hack the JSON code to put(letter (3) of (Var))in the variable dropdown inset [ v] to [6]which isn't possible in “normal” Scratch.
You can do this by downloading the project (or make a new, blank project and backpack it later), unzipping it, and opening the project.json file. Look for something similar toand replace"scripts": [[10, 10, [["letter:of:", 3, "string"]]],
[10, 40, [["setVar:to:", "variable", 0]]]],with[10, 40, [["setVar:to:", "variable", 0]]]],Rezip the file and rename it something.sb2, then open it in the Scratch editor. It should work."scripts": [[10, 10, [["letter:of:", 3, "string"]]],
[10, 40, [["setVar:to:", ["letter:of:", 3, "abc"], 0]]]],
Or, if you like, I've shared a project with the block: https://scratch.mit.edu/projects/80799944/ You can go inside and put the block into your backpack, then use it in another project.
- ChocolatePi
-
Scratcher
1000+ posts
can someone please give me a script that works like this?
What are you trying to accomplish here? Do you have a bunch of variables that are single letters and Var is a word with a bunch of characters?
- Aaronhoffer
-
Scratcher
100+ posts
can someone please give me a script that works like this?
sheesh a new block needs to be made lol anyway thx
- Discussion Forums
- » Questions about Scratch
-
» can someone please give me a script that works like this?








