I got all 3 cameras to take around 5,000 pictures each through an entire sunset, without a script interrupt. Hurrah!
This is with wait_shot_ready() and set_yield(-1,-1). The script actually works better with the yield hook disabled. I haven't found the cause of the bug, but at least I have a way to work around it now, and make sure I get a complete time lapse.
The next step is to see if the bug happens with the yield hook enabled. For a good test, I'll try set_yield(1,10), for a yield every 200 lua operations. My guess is that the yield hook won't trigger the bug, and that it comes from the transition from Lua to a C subroutine getting the stack wrong or something. My wait_shot_ready() has no parameters. Maybe I'll try it with a dummy parameter and see if that causes trouble.
I would like to have an escape option for wait_shot_ready() when you press a key, so a parameter might be useful. One thing I'm wondering is how I can return a value from wait_shot_ready?
Could I end wait_shot_ready() with:
return lua_yield( L, 1 ); ??
Then, I would use lua_pushnumber() from the action stack routine when it finishes?
Speaking of action stacks, maybe that could be causing this lua problem. There's a lot of pushing and popping going on with a function like sleep(10). I haven't gone through all the action stack logic, but it might be worth it to follow the code for a sleep(10) call from start to finish.