For future reference, this works.
The probe file can be adjusted to allow for different types of probing.
if !exists(param.X) || !exists(param.Y) ;if parameter X and Y are given
echo "Make sure parameter X and Y are given (C and S optional). Aborting probe move." ;notify user
G1 X{param.X} Y{param.Y} Z{sensors.probes[0].diveHeight} F6000 ;move to given X and Y coordinates and predefined diveheight
M400 ;wait for moves to finish
M98 P"waitForHeaters.g" H01
M568 P0 A0 ;turn the extruder heater off (interference changes sensor reading)
G4 S1 ;wait 1 second
M98 P"preprobe.g" ;call macro to determine triggervalue and see if it is okay to proceed probing
;M291 R"Probing." P" " S1
if global.proceedProbe = true ;if its okay to proceed probing
if exists(param.C) ;if parameter C is given
if exists(param.S) ;if parameter S is given
G30 X{param.X} Y{param.Y} P{param.C} S{param.S} Z-9999 ;probe move
else ;otherwise
G30 X{param.X} Y{param.Y} P{param.C} Z-9999 ;probe move
elif exists(param.S) ;if parameter S is given
G30 X{param.X} Y{param.Y} S{param.S} Z-9999 ;probe move
else ;otherwise
G30 X{param.X} Y{param.Y} Z-9999 ;probe move
elif (global.proceedProbe = false) ;if it isnt okay to proceed probing
echo "Aborting probe move" ;notify user
;M292
M568 P0 A1 ;set the extruder heater to standby
if global.bedLeveled == 0
G32
M98 P"probe.g" X525 Y250
echo >"heightmap.csv" "Height map file generated at", state.time
echo >>"heightmap.csv" "xmin,xmax,ymin,ymax,radius,xspacing,yspacing,xnum,ynum"
echo >>"heightmap.csv" global.xMin,",",global.xMax,",",global.yMin,",",global.yMax, ", -1 ,",global.xSpacing,",",global.ySpacing,",",global.xNum,",",global.yNum
var y = global.yMin
var i = 0
G90
while var.i < global.yNum
var x = global.xMin
var j = 0
while var.j < global.xNum
M98 P"probe.g" X{var.x} Y{var.y} S-1
M400
if var.j == 0
set global.meshLine = sensors.probes[0].lastStopHeight - sensors.probes[0].triggerHeight
else
set global.meshLine = global.meshLine ^ "," ^ sensors.probes[0].lastStopHeight - sensors.probes[0].triggerHeight
set var.x = var.x + global.xSpacing
set var.j = var.j + 1
echo >>"heightmap.csv" global.meshLine
set var.y = var.y + global.ySpacing
set var.i = var.i + 1