--[[ This header can not be removed Copyright Newfangled Solutions (c) 2015 All Rights Reserved, www.machsupport.com THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. Author - Newfangled Solutions Liscence - mit Date - 07/08/2015 Summary - This code is used to turn on an output by an Mcode in Mach4 to select the next tool in the pgm. Plus validation of tools. --]] function m6() inst = mc.mcGetInstance(); local NewTool = mc.mcToolGetSelected(inst);--Get the next tool they would like to have --Toolchange Script --ROB add a check here to see if this tool is a valid tool local CurTool = mc.mcToolGetCurrent(inst);--Get the next tool they would like to have --Toolchange Script if(CurTool == NewTool)then return;--Nothing to do here if it is the same tool end --Setup the table of outputs so anyone can remap what outputs go to what tools local outputs={}; outputs[1] = mc.OSIG_OUTPUT0; outputs[2] = mc.OSIG_OUTPUT1; outputs[3] = mc.OSIG_OUTPUT2; outputs[4] = mc.OSIG_OUTPUT3; outputs[5] = mc.OSIG_OUTPUT4; outputs[6] = mc.OSIG_OUTPUT5; --Setup the registers and turn off all outputs local outHsig={}; for i=1,6, 1 do outHsig[i] = mc.mcSignalGetHandle(inst, outputs[i]);--Get the handle mc.mcSignalSetState(outHsig[i], 0);--Turn it off end --Turn on the output that we would like to have and we are done here if(outHsig[NewTool] ~= nil)then mc.mcSignalSetState(outHsig[NewTool], 1);--Turn it off end end --This function is used to allow the debugging to be done in the mcLua editor if (mc.mcInEditor() == 1) then dofile ("load_modules.mcs") m6() end