Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- redstone.setAnalogOutput("back", 0)
- local monitors = { peripheral.find("monitor") }
- local monitor = nil
- local y = 1
- local width, height = nil, nil
- if #monitors ~= 0 then
- monitor = monitors[1]
- monitor.setTextScale(1)
- width, height = monitor.getSize()
- if width < 29 then
- monitor.setTextScale(1)
- y = 3
- elseif width == 29 then
- monitor.setTextScale(1.5)
- y = 2
- elseif width > 29 then
- monitor.setTextScale(2)
- y = 1
- end
- width, height = monitor.getSize()
- term.redirect(monitors[1])
- term.setCursorPos(1, y)
- else
- print("no monitors")
- end
- local pst = -8
- local offset = pst * 60 * 60 * 1000
- --times 1000 to turn it into milliseconds
- local newYearsEpoch = 1735689600 * 1000
- term.setCursorBlink(false)
- term.clear()
- local function padCenter(str, width)
- local strLen = #str
- if strLen >= width then
- return str
- end
- local totalPadding = width - strLen
- local leftPadding = math.floor(totalPadding / 2)
- local rightPadding = totalPadding - leftPadding
- return string.rep(" ", leftPadding) .. str .. string.rep(" ", rightPadding)
- end
- while true do
- local currentEpoch = os.epoch("utc")
- local pstEpoch = currentEpoch + offset
- local epochLeft = newYearsEpoch - pstEpoch
- local remainingTime = math.floor(epochLeft / 1000)
- local milliseconds = epochLeft % 1000
- local days = math.floor(remainingTime / 86400)
- remainingTime = remainingTime % 86400
- local hours = math.floor(remainingTime / 3600)
- remainingTime = remainingTime % 3600
- local minutes = math.floor(remainingTime / 60)
- local seconds = remainingTime % 60
- local message = ""
- term.setCursorPos(1, y)
- if epochLeft <= 0 then
- redstone.setAnalogOutput("back", 15)
- term.clear()
- message = "Happy New Years!!!"
- message = padCenter(message, width)
- print(message)
- break
- end
- --remove ":%03d" if you dont like the look of milliseconds
- --this will mean that it will print all zeros before triggering new years
- message = string.format("%02d:%02d:%02d:%02d:%03d", days, hours, minutes, seconds, milliseconds)
- message = padCenter(message, width)
- print(message)
- --print(term.getSize())
- sleep(0)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement