Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: Eveider on November 03, 2022, 06:44:35 AM
-
hi there
I am looking for a way to turn ON an output and turn it OFF after 5 seconds.
I managed to write a lua code in the signal script that basically turn ON and OFF an output but now i am struggling to implement a delay
-- code
local inst = mc.mcGetInstance()
local hsig = mc.mcSignalGetHandle(inst,mc.ISIG_INPUT1)
local ISigFDBK = mc.mcSignalGetState(hsig)
local hsignal = mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT5)
local OSigFDBK = mc.mcSignalGetState(hsignal)
if (ISigFDBK == 0)then
mc.mcSignalSetState(hsignal,1)
else
mc.mcSignalSetState(hsignal,0)
end
-
wx.wxMilliSleep(3000)
That is a 3 second delay
-
Should have read that a little better.
if (ISigFDBK == 0)then
mc.mcSignalSetState(hsignal,1)
wx.wxMilliSleep(5000)
mc.mcSignalSetState(hsignal,0)
end
-
This is why your are not supposed to cross post (same question in multiple posts). I answered your question in another post. See https://www.machsupport.com/forum/index.php?topic=41633.msg294381#msg294381 (https://www.machsupport.com/forum/index.php?topic=41633.msg294381#msg294381).
Steve