Here ya go. Try this. I had to put Lua to sleep for 5 seconds to let Mach4 report, exit, enter the appropriate machine state to continue.
The 5 seconds should be reset to the time it takes for your machine to home the X axis. To fast and Mach4 cannot properly communicate with the controller. In the simulator, I had it as fast as 2 seconds. But that's the sim and not real life. After the m101 macro, the X axis is re-homed, the next block of gCode is executed.
function m101 ()
local inst = mc.mcGetInstance ()
mc.mcCntlCycleStop (inst)
mc.mcAxisHome (inst, 0)
wx.wxSleep (5)
mc.mcCntlCycleStart (inst)
end
Sample gCode:
G00 G90 Z0.0
X4.5 Y3.5
m101
X2.5 Y1.5
m101
X1.333 Z2.123
X3.6 Z4.234
m101
X1.0 Y1.0 Z0.0
m02
Hope this helps a little. --josh