Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Needs a monitor four blocks wide.
- -- Text counts down in white until the next predicted Minecraft server reboot.
- -- If the server stays up longer than predicted, text turns grey and starts counting
- -- upwards to indicate current uptime instead.
- -- Prediction is based upon the longest uptime encountered.
- local mon = peripheral.find("monitor")
- local counter, maxCount = 0, 0
- if fs.exists("lastTime") then
- local input = io.open("lastTime", "r")
- maxCount = tonumber(input:read())
- input:close()
- end
- print("Last uptime " .. (maxCount / 60) .. " minutes (" .. (maxCount / 3600) .. " hours).")
- mon.setTextColour(colours.white)
- mon.setBackgroundColour(colours.black)
- mon.setTextScale(5)
- while true do
- if counter == maxCount then mon.setTextColour(colours.grey) end
- local thisTime
- if counter > maxCount then
- if counter % 60 == 0 then
- local output = io.open("lastTime", "w")
- output:write(counter)
- output:close()
- end
- thisTime = counter
- else
- thisTime = maxCount - counter
- end
- local hours = tostring(math.floor(thisTime / 3600))
- if #hours == 1 then hours = "0" .. hours end
- thisTime = thisTime % 3600
- local minutes = tostring(math.floor(thisTime / 60))
- if #minutes == 1 then minutes = "0" .. minutes end
- local seconds = tostring(thisTime % 60)
- if #seconds == 1 then seconds = "0" .. seconds end
- mon.setCursorPos(1, 1)
- mon.write(hours .. ":" .. minutes .. ":" .. seconds)
- sleep(1)
- counter = counter + 1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement