I have a script which does "stacking" of both focus and exposure.
I use it to photograph the internals of engines or amplifiers (don't ask).
it runs fine, and does almost exactly what I want.
I normally run it in Manual mode, with the focus preset and locked. This is
(in effect) how I tell the script the starting conditions.
After the script has run, I wish the camera to be as it was before the script is run.
This means I can run the script repeatedly.
Sadly, my "restore" function doesn't work, and I don't understand why.
The code is pretty simple (although I did have a bit of a run-in with Lua's
"global variables by default" concept).
Script, and a log run attached.