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

Help with timer.

Started by korupt_virus, 24 March 2012 - 02:04 PM
korupt_virus #1
Posted 24 March 2012 - 03:04 PM
i need help with a script that will send a redstone signal until a displayed on screen counter is done counting to 100. i've tried using a for loop but cant get it down right. someone please help?
kamnxt #2
Posted 24 March 2012 - 03:08 PM
Try this:

side = "back" --redstone side
rs.setOutput(side,true) --turn redstone on
for i=1, 100 do
--write i to the screen
term.setCursorPos(1,1)
print(i)
sleep(0.1)
end
rs.setOutput(side,false) -- turn redstone back off
Liraal #3
Posted 24 March 2012 - 03:08 PM
rs.setOutput("front", true)
for i=1, 100 do
print(i) sleep(0.1)
end
rs.setOutput("front",false)

edit: i wasn't fast enough
korupt_virus #4
Posted 24 March 2012 - 06:44 PM
i was wondering how that may be used in seconds?
kamnxt #5
Posted 24 March 2012 - 07:05 PM
Do you mean to set the amount of seconds counting from 1 to 100 will take?

side = "back" --redstone side
delay = 5 --The time it will take to count from 1 to 100
delay = delay/100
rs.setOutput(side,true) --turn redstone on
for i=1, 100 do
--write i to the screen
term.setCursorPos(1,1)
print(i)
sleep(delay)
end
rs.setOutput(side,false) -- turn redstone back off
korupt_virus #6
Posted 24 March 2012 - 07:16 PM
thank you :(/>/>
NeoHummel #7
Posted 24 March 2012 - 07:17 PM
sleep() takes an argument in seconds for how long to wait, so you could use sleep(1) to make it wait 1second.