title: Lua Accessing a table's Keys and Values
body: <p>I would like to read a Lua file in a level editor so I can display its data in visual format for users to edit.</p>
  
  <p>If I have a Lua table like so: </p>
  
  <pre><code>properties = {
    Speed = 10,
    TurnSpeed = 5
  }
  </code></pre>
  
  <p><code>Speed</code> is obviously the key and <code>10</code> the value. I know I can access the value if I know the key like so (provided the table is already on the stack):</p>
  
  <pre><code>lua_pushstring(L, "Speed");
  lua_gettable(L, idx); 
  int Speed = lua_tointeger(L, -1);
  lua_pop(L, 1); 
  </code></pre>
  
  <p>What I want to do is access the key's name and the corresponding value, in C++. Can this be done? If so how do I go about it?</p>