I know that there are other answers out there for this, but none like the way I have it.
for i,v in pairs(Waypoints) do
if (i%2 == 1) then
Waypoints[i] = nil
else
i = i/2 --- The part I need help with the most.
end
end
Basically, what I’ll explain what this does, and then I need help with after.
So, this table is basically composed of multiple tables. Each table inside the main table has a value of a position that separates it 4 studs away from all other mini-tables. I wanted to increase this to 8 studs away from each other. Therefore, it got rid of half of the indexes by getting rid of all odd numbers.
Now, the problem is the indexes are now not in order. They were originally listed as:
local table = {1,2,3,4,5,6,7,8,9,10} --- Not used in the code, just used as a example.
Now, after that action takes place. They’re now listed as:
local table = {2,4,6,8,10} --- Not used in the code, just used as a example.
My question is how do I sort them all back in a numerical order. I am not the most experienced with tables, so I don’t know how to resort all of them, or divide their index number by half.
The goal is to have the table laid out like this:
local table = {1,2,3,4,5} --- Not used in the code, just used as a example.
How, do I go about that?