Need A Way Of Organizing Clones Based on Clone ID

id: 749502

category: Help with Scripts

posts: 6

kanomaster 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:
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!
Jack2888 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
something like
set x to (((ID) mod [5]) * [50])
set y to (([floor v] of ((ID) / [5])) * [30])
should get you a lot closer to your objective
kanomaster kanomaster loading

Jack2888 wrote:

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
Thanks! That'll work great!

MultiTasker801 wrote:

something like
set x to (((ID) mod [5]) * [50])
set y to (([floor v] of ((ID) / [5])) * [30])
should get you a lot closer to your objective
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!
kanomaster kanomaster loading

MultiTasker801 wrote:

something like
set x to (((ID) mod [5]) * [50])
set y to (([floor v] of ((ID) / [5])) * [30])
should get you a lot closer to your objective
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)
Jack2888 Jack2888 loading

kanomaster wrote:

MultiTasker801 wrote:

something like
set x to (((ID) mod [5]) * [50])
set y to (([floor v] of ((ID) / [5])) * [30])
should get you a lot closer to your objective
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)
Good thing this works