This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
geezuzraptr123's profile picture

Lua- Timers

Started by geezuzraptr123, 02 September 2012 - 02:59 PM
geezuzraptr123 #1
Posted 02 September 2012 - 04:59 PM
I'm new at computer craft and i've been looking everywhere for Youtube videos on how to make a timer (like every 0.2 seconds it turns on a redstone signal) but I just can't seem to find any. I would appreciate it if someone could help me out :D/>/>
BigSHinyToys #2
Posted 02 September 2012 - 05:10 PM
This should do it


local side = "back" -- this is the side
local pause = 0.2 -- this is 0.2 seconds
while true do
    sleep(pause)
    rs.setOutput(side,true)
    sleep(pause)
    rs.setOutput(side,false)
end
Kingdaro #3
Posted 02 September 2012 - 05:11 PM
You could just use a while loop with a sleep:


while true do
  rs.setOutput('back', true)
  sleep(0.2)
  rs.setOutput('back', false)
  sleep(0.2)
end

There's also the "redpulse" program.

EDIT: I really hate ninjas.
Mtdj2 #4
Posted 02 September 2012 - 05:13 PM
Change "sleep(pause)" to "sleep(pause / 2)"
As far as I know, sleep(1) is a 2 second delay.
BigSHinyToys #5
Posted 02 September 2012 - 05:18 PM
Change "sleep(pause)" to "sleep(pause / 2)"
As far as I know, sleep(1) is a 2 second delay.

No it is one second to quote the help for sleep()
sleep makes the computer idle for a specific number of seconds.

ex:
"sleep 10" puts the computer to sleep for 10 seconds
geezuzraptr123 #6
Posted 02 September 2012 - 11:31 PM
Thank you i would never be able to do this but i'm ready to learn :D/>/>
geezuzraptr123 #7
Posted 03 September 2012 - 12:03 AM
so would i type lua and then copy and paste this down? =3
geezuzraptr123 #8
Posted 03 September 2012 - 03:53 AM
how would u use redpulse to make it infanite?
sjele #9
Posted 03 September 2012 - 04:46 PM
so would i type lua and then copy and paste this down? =3

To store a program do
edit test –Test is program name
–in there put the code
ctrl s then ctrl e.
Now type: test –And it should run