title: index negative number in array in lua
body: <p>problem: I have an array called <code>X</code>. <code>X[1:20]</code>. I initialized to 0 to start with. </p>
  
  <p>I want to pass a  number to each element of array after adding 1 to it. So I read number  and store in local variable <code>z</code>. sometimes "number" can be positive and negative. </p>
  
  <p>However, array is only for positive (i.e. x [1....20] ) 
  When "number" is negative lua gives error message that "attempt to perform arithmetic on field '?' (a nil value). </p>
  
  <p>What should I do? </p>
  
  <pre><code>local x= {}
  local number
  local z
  
  for i = 1, 20 do 
  
      x [i] = 0;  -- array initialization 
  end 
  
  for y = 1, 5 do 
  
   z  = number   -- I am reading a "number" from hardware &amp; it is a negative     integer number
  
   x[z] = x[z]+1 ; 
  end
  </code></pre>