AvailableSpots = { ["1"] = true; ["2"] = true; ["3"] = true; } for i,v in pairs(AvailableSpots) do print(i) print(v) end
output
1 true 3 true 2 true
Why does it skip to 3? How would I fix this?
The order a table is written in is not preserved unless your keys are numerical. In your case, this shouldn't be a problem, as your string keys can just as easily be numbers:
AvailableSpots = { [1] = true; [2] = true; [3] = true; } for i, v in pairs(AvailableSpots) do print(i, v) end