Hello,
function m6()
local inst = mc.mcGetInstance();
local xstart = mc.mcAxisGetPos(inst,0)
local ystart = mc.mcAxisGetPos(inst,1)
local guesslen = -100
local selectedtool = mc.mcToolGetSelected(inst)
local currenttool = mc.mcToolGetCurrent(inst)
local toollen = mc.mcToolGetData(inst, mc.MTOOL_MILL_HEIGHT, currenttool)
if toollen == 0 then toollen = 50 end
local probestart = guesslen + toollen
if (selectedtool == currenttool) then
return
mc.mcCntlSetLastError(inst, "Selected Tool = Current Tool, proceeding")
else
rc = mc.mcCntlGcodeExecuteWait(inst,"M05")
rc = mc.mcCntlGcodeExecuteWait(inst,"M09")
rc = mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G00 Z0.000")
rc = mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G00 X1.700 Y1.100")
rc = mc.mcCntlGcodeExecuteWait(inst,"G04 P4000")
rc = mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G00 Z"..probestart)
rc = mc.mcCntlGcodeExecuteWait(inst,"G91 G31 Z-60 F300")
rc = mc.mcCntlGcodeExecuteWait(inst,"G91 Z.1")
rc = mc.mcCntlGcodeExecuteWait(inst,"G91 G31 Z-60 F50")
rc = mc.mcCntlGcodeExecuteWait(inst,"M07")
local toolz = mc.mcAxisGetPos(inst,2)
rc = mc.mcCntlGcodeExecuteWait(inst,"M09")
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G00 Z0.000")
local changetoo = mc.mcToolGetDesc(inst, selectedtool)
wx.wxMessageBox("Please change to tool number "..selectedtool.." "..changetoo.." and press OK to continue")
currenttool = selectedtool
rc, toollen = mc.mcToolGetData(inst, mc.MTOOL_MILL_HEIGHT, currenttool)
if toollen == 0 then toollen = 50 end
probestart = guesslen + toollen
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G00 X1.700 Y1.100")
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G00 Z"..probestart)
rc = mc.mcCntlGcodeExecuteWait(inst, "G91 G31 Z-60 F100")
rc = mc.mcAxisSetPos(inst, 2 , toolz)
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G00 Z0.000")
-- mc.mcCntlGcodeExecuteWait(inst,"M03")
-- mc.mcCntlGcodeExecuteWait(inst, "G90 G00 X"..xstart)
-- mc.mcCntlGcodeExecuteWait(inst, "G90 G00 Y"..ystart)
rc = mc.mcCntlGcodeExecuteWait(inst, "G90 G00 X"..xstart.." Y"..ystart)
-- mc.mcCntlGcodeExecuteWait(inst,"G04 P3000")
rc = mc.mcToolSetCurrent(inst, selectedtool)
rc = mc.mcCntlSetLastError(inst, "Toolchange Finished")
--wx.wxMessageBox('Toolchange Finished')
end
end
if (mc.mcInEditor() == 1) then
m6()
end
This should help, I haven't tested it myself obviously.
If it doesn't work let me know and I'll swap some stuff around, I tried to do some housekeeping with the return codes but I'm slack with them too

Also remember probing speed has a great deal to do with accuracy, sometimes slowing down will speed you up!
Let me know how it goes.