Maybe this will help get you started:
--[[
Macro to set Z or X offset or tool description
example: m6061 z1.3333 d.250
--]]
function m6061(hParam)
if (hParam ~= nil) then
--mc.mcCntlSetLastError(inst, 'handle == ' .. tostring(hParam));
local inst = mc.mcGetInstance();
local zVal = mc.mcCntlGetLocalVar(inst, hParam, mc.SV_Z)
local zFlag = mc.mcCntlGetLocalVarFlag(inst, hParam, mc.SV_Z)
local xVal = mc.mcCntlGetLocalVar(inst, hParam, mc.SV_X)
local xFlag = mc.mcCntlGetLocalVarFlag(inst, hParam, mc.SV_X)
local dVal = mc.mcCntlGetLocalVar(inst, hParam, mc.SV_D)
local dFlag = mc.mcCntlGetLocalVarFlag(inst, hParam, mc.SV_D)
if(zFlag == 1)or(xFlag==1)or(dFlag==1) then
if zFlag==1 then
rc=mc.mcToolSetData(inst,mc.MTOOL_LATHE_Z,61,tonumber(zVal))
end
if xFlag==1 then
rc=mc.mcToolSetData(inst,mc.MTOOL_LATHE_X,61,tonumber(xVal))
end
if dFlag==1 then
rc=mc.mcToolSetDesc(inst,61,'Bit Diameter: '..tostring(dVal))
end
else if zFlag==1 then
mc.mcCntlSetLastError(inst, 'ERROR: Z, X or D value required with M6061');
mc.mcCntlEStop(inst);
end
end
else
mc.mcCntlSetLastError(inst, 'ERROR: handle == nil');
end
end
if (mc.mcInEditor() == 1) then
m6061()
e