Need A Way Of Organizing Clones Based on Clone ID
id: 749502
category: Help with Scripts
posts: 6
Mar 22, 2024 19:21:53
Need A Way Of Organizing Clones Based on Clone ID
view on scratch
view on legacy ocular
kanomaster
loading
Alright, so let's say I have 20 different clones that are buttons. (The functionality of the buttons doesn't matter for this question). Each of the clones spawns in with it's own variable called “ID” (which is set as “for this sprite only”) Based off of this I can say:
1 2 3 4 5 6 7 8 9 10…. (goes past edge of screen)
Whereas I want something that loops back when a certain number of buttons are in one row: like
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
How would one go about doing this? Thanks!
set x to ((ID) * (50))This will make all of the buttons spaced apart by 50, but they will eventually go off the screen. It looks like:
1 2 3 4 5 6 7 8 9 10…. (goes past edge of screen)
Whereas I want something that loops back when a certain number of buttons are in one row: like
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
How would one go about doing this? Thanks!
Mar 22, 2024 19:54:58
Need A Way Of Organizing Clones Based on Clone ID
view on scratch
view on legacy ocular
Jack2888
loading
you could just do something like this:]
set [foo v] to [0]
set y to ((foo) * (20))
if <(id) > [whatever length]> then
set y to ((foo) * (20))
change [foo v] by (1)
end
Mar 22, 2024 19:55:21
Need A Way Of Organizing Clones Based on Clone ID
view on scratch
view on legacy ocular
MultiTasker801
loading
something like
set x to (((ID) mod [5]) * [50])should get you a lot closer to your objective
set y to (([floor v] of ((ID) / [5])) * [30])
Mar 22, 2024 20:17:03
Need A Way Of Organizing Clones Based on Clone ID
view on scratch
view on legacy ocular
kanomaster
loading
Thanks! That'll work great! you could just do something like this:]set [foo v] to [0]
set y to ((foo) * (20))
if <(id) > [whatever length]> then
set y to ((foo) * (20))
change [foo v] by (1)
end
That would work great but I have another thing that complicated that idea so the first idea would work best. I figured that using a variable would be the best way, but I wanted to see if there was a super technical method of doing so. Thanks y'all! something likeset x to (((ID) mod [5]) * [50])should get you a lot closer to your objective
set y to (([floor v] of ((ID) / [5])) * [30])
Mar 22, 2024 22:44:15
Need A Way Of Organizing Clones Based on Clone ID
view on scratch
view on legacy ocular
kanomaster
loading
Never mind, this actually was the best way. But instead of mod 5, it needs to be mod 5.000000001 (in order to keep the 5 from being in front) something likeset x to (((ID) mod [5]) * [50])should get you a lot closer to your objective
set y to (([floor v] of ((ID) / [5])) * [30])
Mar 23, 2024 17:08:04
Need A Way Of Organizing Clones Based on Clone ID
view on scratch
view on legacy ocular
Jack2888
loading
Good thing this worksNever mind, this actually was the best way. But instead of mod 5, it needs to be mod 5.000000001 (in order to keep the 5 from being in front) something likeset x to (((ID) mod [5]) * [50])should get you a lot closer to your objective
set y to (([floor v] of ((ID) / [5])) * [30])