Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Launch monitor prod
- -- function timer
- function timerlaunch()
- local mon = peripheral.find("monitor")
- local nHours = tonumber(0)
- nHours = nHours or 0
- local nMinutes = tonumber(10)
- nMinutes = nMinutes or 0
- local nSeconds = tonumber(0)
- nSeconds = nSeconds or 0
- local totalTime = (nHours * 36000) + (nMinutes * 600) + (nSeconds * 10)
- local hours, minutes, seconds, sHours, sMinutes, sSeconds, sTenths, countdownTimer, timer, _
- if mon then
- local x
- for i = 1, #mon do
- mon[i].setTextColor(colors.white)
- mon[i].setBackgroundColor(colors.black)
- mon[i].clear()
- mon[i].setTextScale(1)
- x = mon[i].getSize()
- if x == 7 then --# width = 1
- mon[i].setTextScale(0.5)
- elseif x == 18 then --# width = 2
- mon[i].setTextScale(nHours < 10 and 2 or 1)
- elseif x == 29 then --# width = 3
- mon[i].setTextScale(3)
- elseif x == 39 then --# width = 4
- mon[i].setTextScale(4)
- elseif x >= 50 then --# width = 5+
- mon[i].setTextScale(5)
- end
- end
- end
- for i = totalTime, 0, -1 do
- hours = totalTime > 35999 and math.floor(totalTime / 36000) or 0
- sHours = tostring(hours)
- minutes = totalTime > 599 and math.floor((totalTime - (hours * 36000)) / 600) or 0
- sMinutes = minutes > 9 and tostring(minutes) or "0" .. tostring(minutes)
- seconds = totalTime > 9 and math.floor((totalTime - ((hours * 36000) + (minutes * 600))) / 10) or 0
- sSeconds = seconds > 9 and tostring(seconds) or "0" .. tostring(seconds)
- sTenths = tostring(math.floor(totalTime - ((hours * 36000) + (minutes * 600) + (seconds * 10))))
- term.setCursorPos(1, 1)
- if totalTime == 0 and term.isColor() then term.setTextColor(colors.red) end
- term.write(sHours .. ":" .. sMinutes .. ":" .. sSeconds .. ":" .. sTenths .. " ")
- if mon then
- for i = 1, #mon do
- mon[i].setCursorPos(1, 2)
- if totalTime == 0 and mon[i].isColor() then mon[i].setTextColor(colors.red) end
- mon[i].write(sHours .. ":" .. sMinutes .. ":" .. sSeconds .. ":" .. sTenths .. " ")
- end
- end
- if totalTime > 0 then
- countdownTimer = os.startTimer(0.1)
- repeat
- _, timer = os.pullEvent("timer")
- if timer == countdownTimer then
- totalTime = totalTime - 1
- end
- until timer == countdownTimer
- end
- end
- end
- -- function end
- local mon = peripheral.find("monitor")
- mon.setTextScale(4)
- mon.clear()
- rednet.open("top")
- mon.setCursorPos(1,1)
- mon.write("Listening")
- mon.setCursorPos(1,2)
- mon.write("for signal")
- local id_1,int_check = rednet.receive()
- local id_2,handshake = rednet.receive()
- local id_3,startcount = rednet.receive()
- local phase2 = false
- repeat
- if int_check == "ping" then
- -- rednet.send(senderId, "pong")
- phase2 = true
- else
- mon.clear()
- mon.setCursorPos(1,1)
- mon.write("Countdown Timer")
- mon.setTextColour(colours.red)
- mon.setCursorPos(1,2)
- mon.write("Aborted due to technical issues")
- sleep(20)
- os.reboot()
- end
- until phase2 == true
- local phase3 = false
- repeat
- if handshake == "1" then
- mon.setCursorPos(1,1)
- mon.write("Countdown Timer")
- mon.setCursorPos(1,2)
- mon.setTextColour(colours.green)
- mon.write("Standby for launch")
- phase3 = true
- else
- mon.clear()
- mon.setCursorPos(1,1)
- mon.write("Countdown Timer")
- mon.setTextColour(colours.red)
- mon.setCursorPos(1,2)
- mon.write("Aborted due to technical issues")
- sleep(20)
- os.reboot()
- end
- until phase3 == true
- local phase4 = false
- repeat
- if startcount == "2" then
- mon.clear()
- timerlaunch()
- phase4 = true
- os.reboot()
- else
- mon.clear()
- mon.setCursorPos(1,1)
- mon.write("Countdown Timer")
- mon.setTextColour(colours.red)
- mon.setCursorPos(1,2)
- mon.write("Aborted due to technical issues")
- sleep(20)
- os.reboot()
- end
- until phase4 == true
- mon.clear()
- mon.setCursorPos(1,1)
- mon.write("Countdown Timer")
- mon.setTextColour(colours.green)
- mon.setCursorPos(1,2)
- mon.write("Completed")
- sleep(10)
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement