title: "Attempt to index local 'self' (a nil value)" cant index variables of my classes
body: <p>I know this question already exists a couple of times on this site, BUT my problem is a little different! So... see my problem is that im trying to get a value in a draw function i wrote for my player class but when im trying to get anything with self.such'n'such it says attempt to index local 'self' (a nil value) the functions arent important for my problem (I hope) </p>
  
  <pre><code>require"functions"
  Acc = 2000
  Decel = 2500
  Maxspd = 900
  
  Player = {}
  Player.__index = Player
  
  function Player:new(x,y)
      local play = {}
      setmetatable(play, Player)
      play.inx = 0
      play.iny = 0
      play.dirx = 0
      play.diry = 0
      play.x = x
      play.y = y
      play.speedx = 0
      play.speedy = 0
      play.velx = 0
      play.vely = 0
      play.clr = "red"
      play.hp = 100
      play.rot = 0
      play.size = 40
      play.hoehe = math.sqrt(3) * (40 / 2)
      return play
  end
  
  function love.load()
      Main = Player:new(100,100)
  end
  
  function Player:update(d)
      if love.keyboard.isDown("w") then self.iny = -1
      elseif love.keyboard.isDown("s") then self.iny = 1 else self.iny = 0 end
      if love.keyboard.isDown("d") then self.inx = 1 
      elseif love.keyboard.isDown("a") then self.inx = -1 else self.inx = 0 end
      if self.inx == -self.dirx then self.speedx = self.speedx / 5 end
      if self.iny == -self.diry then self.speedy = self.speedy / 5 end
      self.dirx = self.inx
      self.diry = self.iny
      if self.inx ~= 0 then self.speedx = self.speedx + Acc * d
          else self.speedx = self.speedx - Decel * d end
      if self.iny ~= 0 then self.speedy = self.speedy + Acc * d
          else self.speedy = self.speedy - Decel * d end
      self.speedx = clamp(self.speedx,0,Maxspd)
      self.speedy = clamp(self.speedy,0,Maxspd)
      self.velx = self.speedx * d * self.dirx
      self.vely = self.speedy * d * self.diry
      self.x = self.x * d
      self.y = self.y * d
  end
  
  function Player:getX() return self.x end
  function Player:getY() return self.y end
  
  function Player:switch()
      if self.clr == "red" then self.clr = "blue" end
      if self.clr == "blue" then self.clr = "red" end
  end
  
  function Player:draw()
      local x1,x2,x3,y1,y2,y3 = 0,0,0,0,0,0
      x1 = self.x - self.size / 2
      y1 = self.y + self.hoehe / 2
      x2 = self.x + self.size/2
      y2 = self.y + self.hoehe / 2
      x3 = self.x
      y3 = self.y - self.hoehe / 2
      x1, y1 = rotate_around_point(x1, y1, self.x, self.y, self.rot)
      x2, y2 = rotate_around_point(x2, y2, self.x, self.y, self.rot)
      x3, y3 = rotate_around_point(x3, y3, self.x, self.y, self.rot)
      local verts = {x1,y1,x2,y2,x3,y3}
      if self.clr == "blue" then love.graphics.setColor(0,255,0,1) end
      if self.clr == "red" then love.graphics.setColor(255,0,0,1) end
      love.graphics.polygon("fill",verts)
  end
  
  function love.keypressed(key,scancode,isrepeat)
      if key == "space" then Main:switch() end
  end
  
  function love.update(d)
      Main:update(d)
  end
  
  function love.draw()
      Main.draw()
  end
  </code></pre>