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

Lever starting CC timer

Started by Hoss85, 27 May 2013 - 03:28 PM
Hoss85 #1
Posted 27 May 2013 - 05:28 PM
Lever starting CC timer

I was wonderin if this is possible and how would i code it. Im wanting to make a lever on the right side of a computer(5x2monitor above), maybe a few blocks away, and have it start a timer at 0 and go up, and when i flip lever off it stops timer and shuts off. Reason for this is because OCS does not display BC engine heat atm(v1.51)so if i make a timer I can know when my water pump engines are heated enough to keep water flowing in combustion engines.

any help is appreciated Thanks.
ikke009 #2
Posted 28 May 2013 - 02:17 PM
something like this might do the trick

local timer = 0
while true do
  os.pullEvent("redstone")
  while rs.getInput("right") == true do
	timer = timer + 1
	sleep(1)
  end
end
You'll have to make a reset button and additional stuff like that yourself
EDIT: the os.pullEvent() function just makes the program freeze untill a redstone event is detected. I did this so the "while true do" loop doesnt keep looping without a reason