I’ve been attempting to get this to work for days. I have this code:
for i,Position in ipairs(Adjacents) do
if FindCubeBasedOnPosition(Position) then
RemoveIndexes[#RemoveIndexes+1] = i
end
end
print(#RemoveIndexes)
for i,v in ipairs(RemoveIndexes) do
table.remove(Adjacents,v)
end
print(#Adjacents)
What this code does is that it takes in a table, a table of, let’s say five (in this case) spots. It iterates through these spots, and checks if that spot is already occupied. If so, then it adds that position to a table. Again, for this example, let’s say that 4 of the 5 spots are occupied. It correctly puts those 4 spots in the table, and when printing #RemoveIndexes it will correctly print out 4.
Alright, everything’s working fine. We then iterate through the RemoveIndexes table, and call table.remove on each index that is in there. Okay, so when we print #Adjacents there should be only one left, right?
NO
I am completely baffled. In my many years of programming on this platform never once have I had this issue. Not once. Please, explain to me what is going on here as I am utterly stumped.
I have run numerous checks, the proper values are stored in RemoveIndexes, which in this case are the values stored at 2, 3, 4, and 5. If I were to replace table.remove with just simply setting the value to nil, it works, however this will break code later on.
I have the same issue with the similar code:
for i,Position in ipairs(Adjacents) do
if FindCubeBasedOnPosition(Position) then
table.remove(Adjacents,i)
end
end
print(#Adjacents)
