Getting the correct focus sounds as simple as making sure that the camera is in the correct shooting modes before proceeding.
Though panning time lapses sound a bit more difficult to script, I will that up to you guys. I don't know BASIC or lua well enough to chime in here!