Advertisement
osmarks

potatochronometer

Mar 26th, 2020
1,295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.75 KB | None | 0 0
  1. local clock = peripheral.find("manipulator", function(_, o) return o.hasModule "minecraft:clock" end)
  2.  
  3. local run = true
  4. while run do
  5.     term.clear()
  6.     term.setCursorPos(1, 1)
  7.     local ms = os.epoch "utc" % 1000
  8.     local gametime = os.time()
  9.     local integer = math.floor(gametime)
  10.     local fractional = gametime - integer
  11.     local gametimestring = ("%02d:%02d"):format(integer, math.floor(fractional * 60))
  12.     local out = {
  13.         {"UTC", (os.date "!%H:%M:%S.%%03d %d/%m/%Y"):format(ms)},
  14.         {"Server time", (os.date "%H:%M:%S.%%03d %d/%m/%Y"):format(ms)},
  15.         {"World time", ("%s on %d"):format(gametimestring, os.day())}
  16.     }
  17.     if clock then
  18.         table.insert(out, {"Celestial angle", ("%f degrees"):format(clock.getCelestialAngle())})
  19.         table.insert(out, {"Moon phase", tostring(clock.getMoonPhase())})
  20.         table.insert(out, {"World time (ticks)", tostring(clock.getTime())})
  21.     end
  22.     textutils.tabulate(unpack(out))
  23.     print "Press ; to exit"
  24.     local timer = os.startTimer(0.05)
  25.     while run do
  26.         local ev, param = os.pullEvent()
  27.         if ev == "timer" and timer == param then
  28.             break
  29.         elseif ev == "char" and param == ";" then
  30.             run = false
  31.         end
  32.     end
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement