Code: Select all
spots = {}
for i=1,9 do
spots[i] = Cardspot:new("fancy", 0, 0, 0, 0)
spots[i].x = 220 + (i%3)*130
spots[i].y = 120 + math.floor(i/3)*150
end
Code: Select all
0%3 = 0; 1%3 = 1; 2%3 = 2;
3%3 = 0; 4%3 = 1; 5%3 = 2;
6%3 = 0; 7%3 = 1; 8%3 = 2
Code: Select all
math.floor(0/3) = 0; math.floor(1/3) = 0; math.floor(2/3) = 0;
math.floor(3/3) = 1; math.floor(4/3) = 1; math.floor(5/3) = 1;
math.floor(6/3) = 2; math.floor(7/3) = 2; math.floor(8/3) = 2
SPOILER: The solutions is either going from 0 to 8 and setting spots[i+1], or going from 1 to 9 and using (i-1) in the math.