Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ######################
- -- ##
- -- ######################
- local bCable = "back" -- Side of your bundled Cable
- local monitor = peripheral.wrap( "right" )
- local timers = { -- Format: {"Starting Mins","Starting Secs",Function to run when done}
- {"0","20",function() rs.setBundledOutput(bCable,colors.combine(rs.getBundledInput(bCable),colors.red)) end},
- {"0","10",function() rs.setBundledOutput(bCable,colors.combine(rs.getBundledInput(bCable),colors.orange)) end}
- }
- --# Returns tTime in a xx:xx format
- local function formatTime(tTime)
- return tTime[1]..":"..tTime[2]
- end
- --# Decrements each timer
- local function updateTime()
- local allDone = true
- for i = 1, #timers do
- if timers[i][2] == "00" then
- if tonumber(timers[i][1]) > 0 then
- timers[i][2] = "59"
- timers[i][1] = tostring(tonumber(timers[i][1]) - 1)
- allDone = false
- elseif type(timers[i][3]) == "function" and not timers[i][4] then
- timers[i][4] = true
- timers[i][3]()
- end
- else
- timers[i][2] = tostring(tonumber(timers[i][2]) - 1)
- if tonumber(timers[i][2]) < 10 then
- timers[i][2] = "0"..(tonumber(timers[i][2]))
- end
- allDone = false
- end
- end
- return not allDone --# Returns 'true' if at least one timer counted down, false if all timers have finished
- end
- --# Prints time to monitor
- local function printTime()
- monitor.setCursorPos(1,6)
- monitor.clearLine()
- monitor.write(" T MINUS "..formatTime(timers[1]).." MINUTES")
- monitor.setCursorPos(1,10)
- monitor.clearLine()
- monitor.write(" T MINUS "..formatTime(timers[2]).." MINUTES")
- end
- -- ######################
- -- ##
- -- ######################
- monitor.setCursorPos(1, 1)
- monitor.setBackgroundColor(colors.black)
- monitor.clear()
- monitor.setTextColor(colors.red)
- monitor.setBackgroundColor(colors.black)
- monitor.setTextScale(1.5)
- monitor.setCursorPos(1, 3)
- monitor.write(" DANGER")
- monitor.setTextColor(colors.red)
- monitor.setBackgroundColor(colors.black)
- monitor.setCursorPos(1, 4)
- monitor.write(" EMERGENCY DESTRUCTION SYSTEM")
- monitor.setTextColor(colors.yellow)
- monitor.setBackgroundColor(colors.black)
- monitor.setCursorPos(1, 5)
- monitor.write(" ON ACTIVATION IT WILL DETONATE IN")
- monitor.setTextColor(colors.yellow)
- monitor.setBackgroundColor(colors.black)
- monitor.setCursorPos(1, 6)
- monitor.write(" T MINUS MINUTES")
- monitor.setTextColor(colors.red)
- monitor.setBackgroundColor(colors.black)
- monitor.setCursorPos(18, 6)
- monitor.write("10:00")
- monitor.setTextColor(colors.red)
- monitor.setBackgroundColor(colors.black)
- monitor.setCursorPos(1, 8)
- monitor.write(" FAILSAFE WARNING")
- monitor.setTextColor(colors.yellow)
- monitor.setBackgroundColor(colors.black)
- monitor.setCursorPos(1, 9)
- monitor.write(" CUT-OFF SYSTEM WILL NOT OPERATE AFTER")
- monitor.setTextColor(colors.yellow)
- monitor.setBackgroundColor(colors.black)
- monitor.setCursorPos(1, 10)
- monitor.write(" T MINUS MINUTES")
- monitor.setTextColor(colors.red)
- monitor.setBackgroundColor(colors.black)
- monitor.setCursorPos(19, 10)
- monitor.write("5:00")
- while true do
- os.pullEvent("redstone")
- if rs.getInput("left") then
- local timerID = os.startTimer(1)
- while true do
- local event = { os.pullEvent() }
- if event[1] == "timer" and event[2] == timerID then
- if not updateTime() then break end --# Stops when all functions have reached 0:00
- printTime()
- timerID = os.startTimer(1)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment