Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How can i copy all content from one list into another?
- Drachenbauer
-
Scratcher
100+ posts
How can i copy all content from one list into another?
Hello
In my game i have a list with the starting-positions of moveable game-elements.
Now i want to copy the whoole content of the list into another one, where i later want to koop progress of movement by changing listitems, while the first one acts as a backup of the starting-positions.
What is the easyest script to add a whoole list into another empty one?
This:
It just creates one single list item with all values joined in a row instead of each value in a separate item like in the first list.
In my game i have a list with the starting-positions of moveable game-elements.
Now i want to copy the whoole content of the list into another one, where i later want to koop progress of movement by changing listitems, while the first one acts as a backup of the starting-positions.
What is the easyest script to add a whoole list into another empty one?
This:
delete (all v) of [progress v]Does not work right.
add (starting :: list) to [progress v]
It just creates one single list item with all values joined in a row instead of each value in a separate item like in the first list.
Last edited by Drachenbauer (Oct. 30, 2021 10:49:11)
- The_Imaginarium
-
Scratcher
1000+ posts
How can i copy all content from one list into another?
Probably looping through the list using an index is best. Though there might be a more clever way.
delete all of [list2 v] :: list
set [index v] to [0]
repeat (length of [list1 v] :: list)
change [index v] by (1)
add (item (index) of [list1 v] :: list) to [list2 v]
end
- MarkGamez
-
Scratcher
31 posts
How can i copy all content from one list into another?
Export the data from the list into a notepad
Once you have your new list press import
Select the notepad
And i think thats it
ohh,
in code,
yeah you might have to follow someone elses advice because they might be correct
Once you have your new list press import
Select the notepad
And i think thats it
ohh,
in code,
yeah you might have to follow someone elses advice because they might be correct
Last edited by MarkGamez (Oct. 30, 2021 11:56:17)
- KloKin
-
Scratcher
18 posts
How can i copy all content from one list into another?
Sorry to necropost, heres a better solution for anyone seeing this in the future
When setting Decoded to nothing, delete every character in its input
On the if, check if its equal to the space character “ ”
This is different because you dont have to make separate scripts for each list, just plug in the list variable into the custom block
lmk if anythings broken
define LoadTrack(track)
set [Track v] to (track)
set [Decoded v] to []
set [i v] to [1]
delete all of [Loaded_Track v]
repeat (length of (Track))
if <(letter (i) of (Track)) = [ ]> then
add (Decoded) to [Loaded_Track v]
set [Decoded v] to []
end
set [Decoded v] to (join (Decoded) (letter (i) of (Track))
change [i v] by (1)
end
add (Decoded) to [Loaded_Track v]
When setting Decoded to nothing, delete every character in its input
On the if, check if its equal to the space character “ ”
This is different because you dont have to make separate scripts for each list, just plug in the list variable into the custom block
lmk if anythings broken
Last edited by KloKin (April 7, 2024 03:51:30)
- Discussion Forums
- » Help with Scripts
-
» How can i copy all content from one list into another?



