Advertisement
znepb

Untitled

Dec 31st, 2020
851
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.53 KB | None | 0 0
  1. local getDistance = require("getDistance")
  2. local monitor = peripheral.find("monitor")
  3. local main = term.current()
  4. local days = {}
  5.  
  6. local function updating()
  7.   term.redirect(monitor)
  8.   term.clear()
  9.   monitor.setTextScale(0.5)
  10.   term.setCursorPos(1, 1)
  11.   monitor.write("updating...")
  12.   term.redirect(main)
  13. end
  14.  
  15. local function update()
  16.   local file = http.get("https://pastebin.com/raw/fgFNryB3#")
  17.   local data = file.readAll()
  18.   days = textutils.unserialize(data)
  19.   table.insert(days, {name = "Glowsquid Server", cs = "opened", time = 1601726400})
  20.   table.insert(days, {name = "Blended school \"will end\"", cu = "", time = 1604067300, removeIfAfter = true})
  21.   file.close()
  22. end
  23.  
  24. updating()
  25. update()
  26.  
  27. local function draw()
  28.   term.redirect(monitor)
  29.   term.clear()
  30.   monitor.setTextScale(0.5)
  31.   term.setCursorPos(1, 0)
  32.  
  33.   for i, v in pairs(days) do
  34.     if v.br then
  35.       print("")
  36.     else
  37.       local str, way = getDistance(v.time)
  38.       if way == 1 and v.removeIfAfter then else
  39.         if way == 0 then
  40.           local is = v.cu or "is"
  41.           local nl = "\n"
  42.           if is ~= "" then
  43.             is = is .. " "
  44.           end
  45.          
  46.           write("\n" .. v.name .. " " .. is .. "" .. str)
  47.         elseif way == 1 then
  48.           local is = v.cs or "was"
  49.          
  50.           if is ~= "" then
  51.             is = is .. " "
  52.           end
  53.           write("\n" .. v.name .. " " .. is .. "" .. str)
  54.         end
  55.       end
  56.     end
  57.   end
  58.   term.redirect(main)
  59. end
  60.  
  61. while true do
  62.   draw()
  63.   sleep(10)
  64. end
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement