How close am I on this attempt to toggle output0 with a button? First time I clicked the button it crashed Mach 4 so I know I messed up something.
[mc.OSIG_ENABLE0] = function (state)-- Motor enable scripting -mac 1/2020
if( state == 1) then
scr.SetProperty('btnMotorEnable', 'Label', 'Motors Enabled');
scr.SetProperty('btnMotorEnable', 'Bg Color', '#C0C0C0');--Light Grey
scr.SetProperty('btnMotorEnable', 'Fg Color', '#808080');--Dark Grey
else
scr.SetProperty('btnMotorEnable', 'Label', 'Motors Disabled');
scr.SetProperty('btnMotorEnable', 'Bg Color', '#C0C0C0');--Light Grey
scr.SetProperty('btnMotorEnable', 'Fg Color', '#808080');--Dark Grey
end
end,
function ServoMotorEnable() -- enable servo motors with button -mac 1/2020
local osig = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT0)
local stat=mc.mcSignalGetState(inst,mc.OSIG_OUTPUT0)
if stat==0 then
mc.mcSignalSetState(osig, 1)
else
mc.mcSignalSetState(osig, 0)
end
end