Hello I am trying to condense this code into a for loop like so:
local theOwnerFlag = _G
for i = 1,10 do
if theOwnerFlag[“flag”…i]==true then
table.insert(picks,theOwnerFlag[i])
end
end
–however it is not registering the insertion of the number into the table. I think I am doing something wrong in the parenthesis. Below is what I started with which works but I need to be more flexible. Also what is a good way to print the corresponding flag. Thank you.
[lua]
if (flag1==true) then
print(‘flag1’)
table.insert(picks, 1)
end
if (flag2==true) then
print(‘flag2’)
table.insert(picks, 2)
end
if (flag3==true) then
print(‘flag3’)
table.insert(picks, 3)
end
if (flag4==true) then
print(‘flag4’)
table.insert(picks, 4)
end
if (flag5==true) then
print(‘flag5’)
table.insert(picks, 5)
end
if (flag6==true) then
print(‘flag6’)
table.insert(picks, 6)
end
if (flag7==true) then
print(‘flag7’)
table.insert(picks, 7)
end
if (flag8==true) then
print(‘flag8’)
table.insert(picks, 8)
end
if (flag9==true) then
print(‘flag9’)
table.insert(picks, 9)
end
if (flag10==true) then
print(‘flag10’)
table.insert(picks, 10)
end
[/lua]