Ways of detecting z changes for timelapse in code

Intend to write a custom Octoprint plugin for controlling an external camera with gphoto2 on the Pi 3. It would base on z changes just like one of the pre-built mode provided under the Timelapse tab. Yet I don't want to have something as sophisticated as Octolapse. I am still fairly new to OP as far as plugin development goes, so this is a bit of a reverse engineering question, please forgive me. Currently I am slicing with Cura 3.6 and directly uploading the gcode files to local.

There's a ZChange event for that:
http://docs.octoprint.org/en/master/events/index.html#gcode-processing