title: Lua. Attempt to index global "a" (a nil value)
body: <p>I'm getting the following error:</p>
  <blockquote>
  <p>Attempt to index global &quot;a&quot; (a nil value)</p>
  </blockquote>
  <pre><code>   local gfx = love.graphics
      return{
          new = function( Image, Animation, Time)        
          return{
          current_frame = 1,
          current_anim = 1,
          image = Image,
          a = Animation,
          play = false,
          time = Time or 0,2,
          counter = 0,
      
          update = function(dt)
          if play then
                      counter = counter + dt
                      if counter &gt;= time then
                          counter = 0
                          current_frame = current_frame + 1
                      end
      
                      if current_frame &gt; #a[current_anim] then
                          current_frame = 1
                      end
                  else
      
                  end
          end,
      
          play = function()
          play = true
          end,
      
          stop = function()
          play = false    
          end,
      
          set_animation = function(anim)
          if anim &gt; #a then error(&quot;there is no animation &quot;, anim) return end
          current_anim = anim
      
          end,
      
          draw = function(data)
          gfx.draw(image, a[current_anim][current_frame], data[1], data[2])
          end
      
          }
          end
      }
      
  </code></pre>
  <p>it seems to me, that I do give &quot;a&quot; a value - a table, containing a set of images, which I assign through second parameter.</p>
  <pre><code>    -----
      
      local quad = love.graphics.newQuad
      local anim_data = {
        quad(0,0, 32, 48, 192, 256),
        quad(32,0, 32, 48, 192, 256),
        quad(64,0, 32, 48, 192, 256),
        quad(96,0, 32, 48, 192, 256),
        quad(129,0, 32, 48, 192, 256),
        quad(162,0, 32, 48, 192, 256)
      
      }
      local image = love.graphics.newImage(&quot;images/player_animation.png&quot;)
      image:setFilter(&quot;nearest&quot;,&quot;nearest&quot;)
  </code></pre>
  <p>Here I supposedly give 'a' a value</p>
  <pre><code>    animation = require(&quot;animations&quot;):new(
              image,
      
              {
                { -- idle
                  anim_data[1]
                },
                { -- walk
                  anim_data[2],
                  anim_data[3],
                  anim_data[4],
                  anim_data[5],
                  anim_data[6]
                },
              },
              
              0.2
            )
      
      animation.play()
  </code></pre>