title: lua using member functions in constructor parameters
body: <p>I'm probably not using the right words in the title since I'm new to lua and it's not exactly OO like I'm used to. So I'll use code to explain myself and what I'm attempting.</p>
  
  <p>I have a class I define by (simplified):</p>
  
  <pre><code>function newButton(params)
    local button, text
    function button:setText(newtext) ... end
    return button
  end
  </code></pre>
  
  <p>I'm trying to create a button that will change it's text once clicked. So I create it as follows(simplified):</p>
  
  <pre><code>local sound = false
  local soundButton = Button.newButton{
    text = "Sound off",
    onEvent = function(event)
      if sound then
        sound = false; setText("Sound on")
      else
        sound = true; setText("Sound off")
      end
    end
  }
  </code></pre>
  
  <p>Which is all good and well, it works except it tells me I can't call setText <code>attempt to call global 'setText' &lt;a nil value&gt;</code> I've tried using <code>soundButton:setText("")</code> but that doesn't work either.<br>
  Is there a pattern I can follow to achieve what I want?</p>