Automated Probe Z-Offset measurement

In my opinion, one of the issues your example above is suffering from is detailed here: Help with Macro: SET_GCODE_VARIABLE doesnt set my variable - #12 by theophile