Hello. I need to center the rows of objects created in a nested loop. My code is this:
local Tab { { ["nestTab"] = { 3, 5, 7 } }, { ["nestTab"] = { 3, 6, 2 } }, }
local xPos = 40
local yPos = 295
local iCnt = 1
for i = 1, #Tab[indX]["nestTab"] do
for j = 1, Tab[indX]["nestTab"][i] do
local btn = widget.newButton(
{
...
}
)
btn.x = xPos * iCnt
btn.y = yPos
iCnt = iCnt + 1
end
yPos = yPos + 40
iCnt = 1
end
In the nested table, each element is a new row, and the value of the elements is the number of objects in this row.
If I use the starting xPos and yPos with an increase in the loop, the rows of objects are left aligned, and I need to be centered. Tell me how to do it better, I think you can use groups here, but I can’t figure out how.