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

[SOLVED] Redstone Output Issue

Started by deactivated1712, 04 September 2012 - 07:04 PM
deactivated1712 #1
Posted 04 September 2012 - 09:04 PM
Hi,
I have a small code that is meant to pulse a wire on the right side of the computer, on and off every second three times. Here is my code:


time = 3
while time > 0 do
rs.setOutput("right", true)
sleep (1)
rs.setOutput("right", false)
time = time -1
end

When I run it the wire stays on permanently until the "time" variable reaches 0. Help?

Thanks, I'm sure it's something obvious and stupid….

H
OmegaVest #2
Posted 04 September 2012 - 09:38 PM
You have no sleep time between off and on, while you do have one between on and off. So, you should have something more akin to this.


local times = 3
local side = "right"
for i = 1, times do
   rs.setOutput(side, true)
   sleep(1.0)
   rs.setOutput(side, false)
   sleep(1.0)
   times = times - 1
end
deactivated1712 #3
Posted 04 September 2012 - 09:53 PM
Thanks :D/>/>