title: Lua: When does it call functions?
body: <p>Using the Love framework by the way.</p>
  
  <p>Ok, so I'm looking to create a random map generation. I obviously only want it drawn once, so I tried to set up a very basic structure. Which isn't working and I can't figure out why.</p>
  
  <pre><code>function love.load()
      testVar = 1
  end
  
  function love.draw()
      if testVar == 1 then
          testFunction()
          love.graphics.print("Update", 20, 200)
      end
  
      love.graphics.print(testVar, 100, 100)
  end
  
  function testFunction()
      love.graphics.print("Success", 20, 300)
      testVar = 0
  end
  </code></pre>
  
  <p>What that is doing is only printing "0", thanks to the command to print testVar up in the draw function. So it seems that it's updating the testVar value without actually running testFunction. Is this something to do with Lua?</p>
  
  <p>For those unfamiliar with Love, love.draw is called every frame, love.load only initially.</p>