Seems to work OK just waiting for the image to show up on the SD:
exp = get_exp_count()
press("shoot_half")
repeat
sleep(50)
until get_shooting() == true
click("shoot_full")
release("shoot_half")
while (get_exp_count() == exp) do
sleep(50)
print("wait...")
end
set_zoom(znext)
FWIW, shoot_full includes shoot_half, so it will be implicitly released after click('shoot_full'). If you wanted to go back to half press, you should use click('shoot_full_only')
To wait for the end of shot, I normally use
repeat sleep(10) until not get_shooting()
This should be later than the exposure count change. shoot() should also block until all this and more is done. However, this didn't seem to be enough in some of my testing. It's possibly using sleep(50) usually gives the extra, but camera and setting specific variations are also likely.
Found a similar crash, going the other direction: zoom-then-shoot. This script:
...works fine the first time, but if you manually move the zoom back to 0 and run it again, it crashes.
I also get the AFScanDriver.c assert (from CaptSeqTask) if I zoom and then immediately press shoot_half. A sleep(100) avoids it. set_zoom should block for the actual time the zoom is moving, so you shouldn't need to account for that.
In normal coding, throwing random delays at crashes is usually considered bad practice, but the way CHDK is hacked into the stock firmware makes it a pretty normal thing for us.