title: Using Lua to define variables of objects in a C++ game
body: <p>This is more of a conceptual question, to help me understand how things work.</p>
  
  <p>In my simple game engine I have a game object class that has all the usual variables, like: position, orientation, scale, velocity, model, texture, and so on.</p>
  
  <p>And now I want to be able to define behaviors of these objects with scripting.
  I understand how I would do that for existing variables. For example, if velocity != 0, change the position.</p>
  
  <p>But how do I define new attributes? (e.g. Health, Ammo)</p>
  
  <p>I can't create new variables in the game object class, since the class is already compiled, and I can't add the variables in the script since it would be reset the next time the behavior script runs.</p>
  
  <p>How are these things usually done in games?</p>