In the game I'm making, I'm developing it mostly in C#, but I'd like to handle some of the game logic using Lua coroutines, because they can represent actions taken over multiple frames nicely. I've never actually used Lua before though so I'm not sure if this will work. Ideally I'd like the C# game update function to be able to add one or more Lua coroutines to be executed to a queue, and then each frame, iterate over the queue, executing each coroutine until it yields or finishes. I just want to know if this is possible, and if so, how to implement it, because it doesn't seem to fit with the "lua_dofile" paradigm that Lua uses.
Here's some C# pseudocode to show what I mean:
GameUpdate()
{
// Update game logic
// (which may add one or more Lua coroutines to the queue)
// Update input, physics, sound, etc
// In Lua:
// For each coroutine in queue,
// execute it until it reaches a yield,
// or it finishes, whichever comes first
}
GameRender()
{
// Render a frame
}
UPDATE: This article (http://www.gamedev.net/topic/585128-luainterface-and-coroutines/) gives the answer I was looking for. In short, it is possible.