Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tArgs = {...}
- if #tArgs < 2 then
- print("Usage: clocker <seconds> <output side> [monitor] [monitor side]")
- print("If a monitor exists, a side must be provided")
- print("Ex: clocker 10 left true right")
- return
- end
- TIME = tonumber(tArgs[1])
- if TIME < 2 then
- print("Seconds must be greater than 1")
- return
- end
- OUTPUT = tArgs[2]
- MONITOR = false
- M_SIDE = "right"
- if #tArgs > 2 then
- if #tArgs < 4 then
- print("Usage: clocker <seconds> <output side> [monitor] [monitor side]")
- print("If a monitor exists, a side must be provided")
- print("Ex: clocker 10 left true right")
- return
- end
- MONITOR = true
- M_SIDE = tArgs[4]
- end
- running = true
- m = peripheral.wrap(M_SIDE)
- while running do
- local time = TIME
- while time >= 0 do
- print(time.." seconds remaining")
- if MONITOR then
- m.clearLine()
- m.setCursorPos(1,1)
- m.write(time)
- end
- local first = os.startTimer(1)
- while true do
- local event, timerID = os.pullEvent("timer")
- if timerID == first then
- time = time - 1
- break
- end
- end
- end
- local second = os.startTimer(1)
- rs.setAnalogOutput(OUTPUT, 15)
- while true do
- local event, timerID = os.pullEvent("timer")
- if timerID == second then
- break
- end
- end
- rs.setAnalogOutput(OUTPUT, 0)
- end
Add Comment
Please, Sign In to add comment