Advertisement
Guest User

Untitled

a guest
Mar 6th, 2013
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. -- shell.run("stateCell")
  2. local tick = 0
  3. local firstTime = true
  4. local activeSide = "right"
  5. local outputSide = "front"
  6. local resetSide = "back"
  7.  
  8. while true do
  9.     if rs.getInput(activeSide) then
  10.         if firstTime then
  11.             print("------------")
  12.             print("Timer Active")
  13.             print("------------")
  14.             print("Waiting for first pulse")
  15.             os.pullEvent("redstone")
  16.             print("First Pulse Recieved")
  17.             firstTime = false
  18.         end
  19.  
  20.         if tick ~= 0 then
  21.             -- 60 Second           
  22.             if math.fmod(tick, 600) == 0 then
  23.                 redstone.setOutput(outputSide, true)
  24.             end
  25.         end
  26.            
  27.         -- Base time interval (1/10 second) == 1 Redstone tick == 2 Game Ticks
  28.         sleep(.1)
  29.         redstone.setOutput(outputSide, false)
  30.         -- Reset tick count in case there is a max int size
  31.         if tick == 36000 or rs.getInput(resetSide) then
  32.             tick = 0           
  33.         end
  34.         tick = tick + 1
  35.     else
  36.         term.clear()
  37.         term.setCursorPos(1,1)
  38.         redstone.setOutput(outputSide, false)
  39.         print("Timer Disabled, Redstone high on ".. activeSide .." to enable.")
  40.         os.pullEvent("redstone")
  41.         if activeSide then 
  42.             firstTime = true
  43.             tick = 0
  44.         end
  45.     end
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement