title: Lua - set a function from a class
body: <p>I am currently trying to learn how to bridge Lua with C++ and write scripts. The problem that I have is that most of the tutorial or documentation is somewhat simplified. Or maybe I have the wrong approach, which is why I am asking here now.</p>
  
  <p>I am trying to initialize the meta table and more specifically. Trying to add functions. Like so;</p>
  
  <pre><code>luaL_Reg rmFuncs[] =
      {
          { "rotate", RotateBlocks },
          { NULL, NULL }
      };
  </code></pre>
  
  <p>But to add RotateBlocks is a bit tricky. All examples that I've found is done in main and not in classes. RotateBlocks is actually Application::RotateBlocks. </p>
  
  <p>So the only way for me to make it work is like this:</p>
  
  <pre><code>static int RotateBlocks(lua_State* L);
  </code></pre>
  
  <p>Is this the only way? Because this causes a lot of problems. As it is static, I cant actually rotate the objects that I want inside the function. Because all my membervalues complain on the function being static.</p>
  
  <p>So how do I actually do anything useful inside my functions and not just printf a random sentence as in all the tutorials or documentation?</p>