title: How can I compress a table after having removed a value from it?
body: <p>I have a table which contains 4 values.</p>
  
  <p>For example:</p>
  
  <pre><code>2
  4
  1
  3
  </code></pre>
  
  <p>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.</p>
  
  <p>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</p>
  
  <p>I'm fairly new to LUA so be gentle with me. :)</p>
  
  <p>What I have is pretty much this:</p>
  
  <pre><code>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 
  </code></pre>
  
  <p>I see where I'm going wrong but I hae no idea how to solve it.</p>
  
  <pre><code>math.random(1,(#ConsoleTable))
  </code></pre>
  
  <p>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.</p>
  
  <p>Am I confusing you? :)</p>