Hello,
Thank you for sharing your knowledge and experience. Perhaps you could point me in the right direction too.
I'm trying to produce a couple M functions to turn on/off Output #2, but I can't get it to work. I will use it to trigger the arc on a welding machine. Here is the code I have for the ON function. I thought of adding the conditional at the end, as suggested in the manual, but that doesn't correct my error.
function m10()
inst=mc.mcGetInstance()
hsig, rc = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT2);
mc.mcSignalSetState(hsig, 1);
end
if (mc.mcInEditor() == 1) then
m10()
end
There is also the option presented in "Down and Dirty “mcLua” scripting, quick ref guide." But I lack the knowledge to initialize the variables at the beginning, so I can't really implement the code. Also, I do not need the IF in the middle, as I just want the state to be ON.
hsig, rc = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT##);
local state = false;
local VarIamTestingFor = SomeThingIamWatchingOrSettingOrValue;
if VarIamTestingFor == WhatSetsTheOutputToOn then
state = true;
else
state = false;
end
mc.mcSignalSetState(hsig, state);
Any help or guidance will be much appreciated.
Cheers