Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local timerLength = 120 --Time in seconds
- local monitorLocation = "top" --The monitor location, it can be monitor_XXX or the side the monitor is on
- local redstoneSide = "right" --What side of the computer the redstone is on
- local redstoneSide2 = "left" --What side of the computer the redstone is on
- local monitor = peripheral.wrap(monitorLocation) -- I get a handle for the monitor
- function SecondsToClock(seconds)
- local seconds = tonumber(seconds)
- if seconds <= 0 then
- monitor.write("00:00");
- else
- mins = string.format("%u", math.floor(seconds/60));
- secs = string.format("%u", math.floor(seconds - mins *60));
- monitor.write(mins)
- monitor.write(":")
- monitor.write(secs)
- end
- end
- function ResetCountDown(number)
- sleep(number)
- monitor.clear()
- rs.setOutput(redstoneSide, false)
- rs.setOutput(redstoneSide2, false)
- os.reboot()
- end
- monitor.setTextColor(colors.orange)
- monitor.setTextScale(4)
- rs.setOutput(redstoneSide, false)
- rs.setOutput(redstoneSide2, false) --put the redstone on
- for i=timerLength, 0, -1 do -- we start the countdown loop
- monitor.setCursorPos(2, 1)
- monitor.clear()-- clear the monitor
- SecondsToClock(i)
- sleep(1) -- let a second pass
- if i == 20 then --check if we have reached 20
- monitor.clear()
- monitor.setCursorPos(1, 1)
- monitor.write("Ignition")
- rs.setOutput(redstoneSide, true) -- make it on
- rs.setOutput(redstoneSide2, true)
- sleep(1)
- end --close the if
- monitor.clear()
- monitor.setCursorPos(1, 1)
- monitor.write("Liftoff")
- end --we close the loop
- sleep(timerLength)
- ResetCountDown(10)
Add Comment
Please, Sign In to add comment