This is the script I am trying to make work
local mInst = 0;  --Sets current controller instance to 0, if running multiple controller instances, this will need to change
local rc = 0;  --Clear rc
local hSig = 0;  --Clear hSig
local inst = mc.mcGetInstance(mInst);  --Captures current instance of Mach 4
 --SETUP OF VARIABLES
local probe = mc.ISIG_PROBE;  --Set input here, mc.<INPUT_NAME>; input needs to be mapped in Mach4
local strikePlateThickness = 0.060;  --What is the thickness of the strikeplate, or how much do you want to offset 0?
 --Function to check to see if probe already grounded
function checkProbe ()
hSig, rc = mc.mcSignalGetHandle(inst, probe);  --Load hReg with probe state
state = mc.mcSignalGetState(hSig);  --Get Signal State
if (state == 1) then  --if hReg true ('if probe is activated then')
return true
else
return false
end
end  --checkProbe()
 --BEGIN
 --Get current Feed rate, G90/G91, G0/G1 states to return to later.
 --Mach4 stores these variables as 'Pound Variables'
 --See Mach4 Lua Scripting Manual Page 23
local CurrFeedRate = mc.mcCntlGetPoundVar(inst, 2134);  --Gets current Feed Rate, #var 2134
local CurrFeedMode = mc.mcCntlGetPoundVar(inst, 4001);  --Gets current G0/G1 state, #var 4001
local CurrPositionMode = mc.mcCntlGetPoundVar(inst, 4003);  --Gets current G90/G91 state, #var 4003
local zProbeStrikePos = 0;  --clear variable
if checkProbe() then  --Check probe status
mc.mcCntlSetLastError(inst, "ERROR: Probe is already triggered.  Cannot continue.");
do return end  --"do return end" stops program. Not sure how this works
end --check if probe is grounded
mc.mcAxisSetPos(inst, 2, 0);  --"Zero Z" (0 is x, 1 y, and so on)
mc.mcCntlGcodeExecuteWait(inst, 'G01 G90 G31 Z-4 F4');  --G31. Machine will stop on probe strike or go to Z-4, store in #var 5063
local zProbeStrikePos = mc.mcCntlGetPoundVar(inst, 5063);  --Get Z strike position
local zAxisCurrentPos = mc.mcAxisGetPos(inst, 2);  --Get Current Z position, sometimes the probe will continue past strike point.
local zAxisDifference = (zProbeStrikePos – ZaxisCurrentPos);  --Gets overshoot, returns positive
local zAxisNewOffset = strikePlateThickness – zAxisDifference;  --Subracts overshoot from known thickness of strikeplate
mc.mcAxisSetPos(inst, 2, zAxisNewOffset);  --Sets DRO to current position
--mc.mcAxisSetMachinePos(inst, 2, zAxisNewOffset);  --Sets Machine to offset if anyone finds this necessary
mc.mcCntlGcodeExecuteWait(inst, 'G00 G91 Z1');  --Rapid move to 1 inch above current pos
local isProbeSafe = checkProbe();  --Checks to see if probe is safe
if isProbeSafe == true then
wx.wxMessageBox("Probe is still activated! Check to make sure probe is not damaged or still contacting strike plate.");
else
mc.mcCntlSetLastError(inst, "Z Axis now referenced.");
end --if