Add this to the beginning of the Screen loading script. Shamelessly stolen from someone here

--//////////////// This is the REQUIRED Header code, Begin //////////////////////
package.path = "./?.lua;c:/Mach4Hobby/Modules/?.mcc;" --where the module file is.
ff = require "FuncModule";--load the module file, call it ff
--/////////////// This is the REQUIRED Header code, End ///////////////////////
create this script in the Modules directory.
function autoSoftLimitsToggle (togglevalue)
local mInst = 0
local rc = 0
local inst = mc.mcGetInstance (mInst)
-- mc.mcCntlSetLastError(inst, 'In Auto Soft Limits Toggle = ');
for i=0, 11 do
if mc.mcAxisIsEnabled (inst,i) == 1 then mc.mcSoftLimitSetState (inst,i,togglevalue) end
end
end
-- End of funcModule.mcs Don't forget to compile this script Doh!
In your PLC script add the following.
package.path = "./?.lua;c:/Mach4Hobby/Modules/?.mcc;" --where the module file is.
ce = require "funcModule";--load the module file, call it ce
Near the end of the PLC add the following
if ((machSoftLimits == 1) and (machState == mc.MC_STATE_IDLE)) then
autoSoftLimitsToggle(1);
machSoftLimits = 0;
end
if (machSoftLimits == -1) then -- Don't care what the state of Mach4 is here. We just are disabling them.
autoSoftLimitsToggle(0);
machSoftLimits = 1;
end
And finally in your Ref All Home button script add the following
machSoftLimits = -1;
This will cause Soft Limits to be turned off while you are Referencing ALL Home. Once homed, Soft Limits will be re-enabled.
I attempted to run the autoSoftLimitsToggle() directly from the button. This would get rid of the machSoftLimits = -1 crap. no matter what I tried this failed.