title: Lua coroutine error: tempt to yield across metamethod/C-call boundary
body: <p>I'm using a game engine that allows you to program in Lua. The game engine commands are in a DLL created from C. There is a exe created in C that calls a Lua file. This Lua file is where you put all your game code including the main loop. There is no going back and forth with the exe, but you can call functions from the DLL. </p>
  
  <p>So in here before the main loop I create a function which I'm going to create a coroutine from. This function iterates over a pretty big table so every n iterations I yield. This function has an infinite while loop around that because I need this stuff to run every single cycle of the main game loop, but it's OK if it's split between multiple cycles. </p>
  
  <p>I then create a coroutine with this function as the parameter. In the main game loop I then resume this coroutine.</p>
  
  <p>When I run my code I get the error: tempt to yield across metamethod/C-call boundary</p>
  
  <p>I was reading some stuff online but not really understanding what the issue is here. Once the exe calls the Lua file it doesn't go back to the exe at all until the Lua file is finished, and since I have my main loop in the Lua file it never finishes in my test case.</p>
  
  <p>What are my options with this then?</p>