Jump to content




[Lua] Redstone timer


3 replies to this topic

#1 xxx

  • New Members
  • 28 posts

Posted 02 August 2012 - 07:37 PM

Hello!
I've tried to make a program which makes the computer emit a constant redstone signal on the right side, and a pulsing signal from the back.
I don't seem to get it right!
Help would be very appreciated! Thank you!

PS; My try:
while true do
rs.setOutput("right",true)
rs.setOutput("back",true)
os.sleep(5)
rs.setOutput("back",false)
end


#2 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 02 August 2012 - 07:43 PM

You need to add a sleep after setting the output to false, or it will inmediately turn it on again. Also, you don't need the first rs.setOutput inside the loop:
rs.setOutput("right", true)
while true do
  rs.setOutput("back", true)
  sleep(2.5)
  rs.setOutput("back", false)
  sleep(2.5)
end
Remember that the time passed to sleep is in seconds, so it sets the output to true, waits 2.5 seconds, turns it off, and waits another 2.5 seconds.

#3 xxx

  • New Members
  • 28 posts

Posted 02 August 2012 - 08:16 PM

Well, thank you! That was pretty obvious, but when you sit and code for a longer time, it may begin to become hard to find the right way.

#4 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 02 August 2012 - 08:21 PM

Well, I didn't see the error at first. It's a really common error to forget that sleep :ph34r:/>





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users