Hello Guest it is April 26, 2024, 12:31:36 AM

Author Topic: delay and timer in signal script #mach 4  (Read 413 times)

0 Members and 1 Guest are viewing this topic.

delay and timer in signal script #mach 4
« 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

 

Offline Bill_O

*
  •  563 563
    • View Profile
Re: delay and timer in signal script #mach 4
« Reply #1 on: November 03, 2022, 01:08:11 PM »
wx.wxMilliSleep(3000)
That is a 3 second delay

Offline Bill_O

*
  •  563 563
    • View Profile
Re: delay and timer in signal script #mach 4
« Reply #2 on: November 03, 2022, 05:29:27 PM »
Should have read that a little better.

if (ISigFDBK == 0)then
   mc.mcSignalSetState(hsignal,1)
   wx.wxMilliSleep(5000)
   mc.mcSignalSetState(hsignal,0)
end

Offline smurph

*
  • *
  •  1,546 1,546
  • "That there... that's an RV."
    • View Profile
Re: delay and timer in signal script #mach 4
« Reply #3 on: November 04, 2022, 03:59:27 PM »
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.

Steve