I have a table which contains 4 values.
For example:
2
4
1
3
I use a function to step through the table looking for, lets say the number 1 by using pairs and to get the position of it in the table.
I then use table.remove to remove 1 from that position. What I would like to do now is to compress the table so that it is 3 values long
2
4
3
I'm fairly new to Lua so be gentle with me. :)
What I have is pretty much this:
CloseRandomConsole = math.random(1,(#ConsoleTable))
If CloseRandomConsole == 1 then
for key, value in pairs(ConsoleTable) do
if value == "1" then
table.remove(ConsoleTable, key)
break
end
end
I see where I'm going wrong but I hae no idea how to solve it.
math.random(1,(#ConsoleTable))
I only want to be able to random between one of the values in the table. And when I have randomed that vlue I want it removed so that I will be left with three other values to random from.
Am I confusing you? :)