Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Mass Duplicating Scripts
- Ronazon7849
-
Scratcher
45 posts
Mass Duplicating Scripts
Hello, Scratch community,
Is there a way to mass duplicate lines of code? I know that right-clicking duplicates it once, but I want to be able to either duplicate it faster or duplicate it like 20 times at once. Does anyone know? If this doesn't exist, it would be a nice feature to add ctrl-c and ctrl-v to copy and paste.
Is there a way to mass duplicate lines of code? I know that right-clicking duplicates it once, but I want to be able to either duplicate it faster or duplicate it like 20 times at once. Does anyone know? If this doesn't exist, it would be a nice feature to add ctrl-c and ctrl-v to copy and paste.
- Purin2022
-
Scratcher
100+ posts
Mass Duplicating Scripts
Hello, Scratch community,Unfortunately, Scratch doesn't really had a way to do that.
Is there a way to mass duplicate lines of code? I know that right-clicking duplicates it once, but I want to be able to either duplicate it faster or duplicate it like 20 times at once. Does anyone know? If this doesn't exist, it would be a nice feature to add ctrl-c and ctrl-v to copy and paste.

The fastest way to do that would be duplicate the whole script and duplicate the whole script again and duplicate the whole script again until it's enough(1 became 2, 2 became 4, 4 became 8 …).

Hopefully you found it helpful!

move () steps
move () steps
move () steps
move () steps
move () steps
move () steps
move () steps
move () steps
move () steps
move () steps
move () steps
move () steps
move () steps
move () steps
move () steps
- medians
-
Scratcher
1000+ posts
Mass Duplicating Scripts
If you want to duplicate it to another object (sprites/the stage), you have to drag the script to that object (as long as it is not selected)
- Xcvfdd
-
Scratcher
500+ posts
Mass Duplicating Scripts
You could use a custom block with the code you want to copy. That way you won’t need to copy the lines of code each time you want to use it.
Example:

Example:

Last edited by Xcvfdd (Jan. 26, 2023 02:47:21)
- deck26
-
Scratcher
1000+ posts
Mass Duplicating Scripts
I'm curious why you'd want to do this though. Generally there are better ways than duplicating large bits of code.
- Ronazon7849
-
Scratcher
45 posts
Mass Duplicating Scripts
You could use a custom block with the code you want to copy. That way you won’t need to copy the lines of code each time you want to use it.
Example:
I don’t know if this would work.
Last edited by Ronazon7849 (Jan. 27, 2023 16:15:09)
- Ronazon7849
-
Scratcher
45 posts
Mass Duplicating Scripts
I'm curious why you'd want to do this though. Generally, there are better ways than duplicating large bits of code.
I'm making a username engine.
- CODER-J
-
Scratcher
80 posts
Mass Duplicating Scripts
Loops are generally a better solution, so long as they are inside of a custom block with the “run without screen refresh” box ticked. It will also make the project load faster.
in stead of
do
in stead of
move (10) steps
move (10) steps
move (10) steps
move (10) steps
move (10) steps
move (10) steps
move (10) steps
move (10) steps
do
define block set to "run without screen refresh"
repeat (8)
move (10) steps
end
Last edited by CODER-J (Jan. 27, 2023 00:24:18)
- Ronazon7849
-
Scratcher
45 posts
Mass Duplicating Scripts
So let me try to explain it better. I’m making a username script that can save usernames, and the way I know how to do it, I would have to do something like this:
Letter converted to number meaning a = 1, f = 6, z = 26, etc.
The first if would have the letter “a”. If it wasn’t “a” it would continue on to the next script where the letter would be “b”, and so on. This would take quite a long time, and I need a better way to do it.
when green flag clicked
set [letter of user] to [0]
repeat (length of (username))
if <<letter (letter of username) of (username)>=[(letter)]> then
Set (user) to (join (user) (join [(space)] [(letter converted to number)]))
change [letter of user] by [1]
end
end
Letter converted to number meaning a = 1, f = 6, z = 26, etc.
The first if would have the letter “a”. If it wasn’t “a” it would continue on to the next script where the letter would be “b”, and so on. This would take quite a long time, and I need a better way to do it.
Last edited by Ronazon7849 (Jan. 27, 2023 16:13:30)
- deck26
-
Scratcher
1000+ posts
Mass Duplicating Scripts
So let me try to explain it better. I’m making a username script that can save usernames, and the way I know how to do it, I would have to do something like this:Set up a list containing the letters (one per item) and use the item # of thing in list. There you have a single block that finds the letter an gives you the corresponding number.when green flag clicked
set [letter of user] to [0]
repeat (length of (username))
if <<letter (letter of username) of (username)>=[(letter)]> then
Set (user) to (join (user) (join [(space)] [(letter converted to number)]))
change [letter of user] by [1]
end
end
Letter converted to number meaning a = 1, f = 6, z = 26, etc.
The first if would have the letter “a”. If it wasn’t “a” it would continue on to the next script where the letter would be “b”, and so on. This would take quite a long time, and I need a better way to do it.
As I said, there should rarely be a need to duplicate code lots of times and this is a prime example. Even without the ‘contains’ block which is a relatively recent addition you could loop through a list of letters to find a match. You should never need to do something like if letter=a, if letter=b, if letter=c ……..
- Discussion Forums
- » Help with Scripts
-
» Mass Duplicating Scripts






