Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: Blacksmith on July 14, 2015, 07:22:48 AM
-
i have this code in the signal script,
if (sig == mc.ISIG_INPUT1) and (state == 1) then
local inst = mc.mcGetInstance()
mc.mcCntlCycleStart(inst)
end
but what if i have two inputs
something like this :
if ((sig == mc.ISIG_INPUT1) and (state == 1)) and ((sig == mc.ISIG_INPUT10) and (state == 1))
local inst = mc.mcGetInstance()
mc.mcCntlCycleStart(inst)
end
how do i do that ?
-
local Input1 = 0;
local Input10 = 0;
local hSig = 0;
hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT1);
Input1 = mc.mcSignalGetState(hSig);
hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT10);
Input10 = mc.mcSignalGetState(hSig);
if (Input1 and Input10 and (state ==1)) then
local inst = mc.mcGetInstance();
mc.mcCntlCycleStart(inst);
end
--Scott
-
thank you its working :))
-
BTW , can i use this method in a sig table also ?
-
yes but it`s a little bit different look in the mach 4 scripting manual it under manuals on mach web site
-
Found out that the piece of script from poppabear isn't working as intended. If you only activate one of either inputs the task wil already be executed.
the correct way to do this is.
local Input1 = 0;
local Input10 = 0;
local hSig = 0;
hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT1);
Input1 = mc.mcSignalGetState(hSig);
hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT10);
Input10 = mc.mcSignalGetState(hSig);
if ((Input1 == 1) and (Input10 ==1)) then
local inst = mc.mcGetInstance();
mc.mcCntlCycleStart(inst);
end
I hope it is to some use.
Marco.
end