Advertisement
Taruu

clock

Jun 14th, 2020
1,277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. --pastebin run tqaNepSZ
  2. local fs = component.proxy(computer.tmpAddress())
  3. local gpu = component.proxy(component.list("gpu")())
  4. screen, _ = component.list("screen")()
  5. gpu.bind(screen)
  6.  
  7. local TIME_ZONE = 0
  8. local t_correction = TIME_ZONE * 3600
  9.  
  10. function floor_to_step(what,step)
  11.     return math.floor(what/step) * step
  12. end
  13.  
  14. local function getRealTime()
  15.     local handle = fs.open("/time", "w")
  16.     local timestamp = fs.lastModified("/time") / 1000 + t_correction
  17.     return os.date("%H:%M:%S %d.%m.%Y", timestamp)
  18. end
  19.  
  20. local function getMinecraftTime()
  21.     local timestamp = os.time()
  22.     year = tostring(tonumber(os.date("%Y",timestamp))-1970)
  23.     if string.len(year) < 3 then
  24.         for i=1,4-string.len(year) do
  25.             year="0"..year
  26.         end
  27.     end
  28.     return os.date("%H:%M:%S %d.%m.", timestamp)..year
  29. end
  30. while true do
  31. realtime = getRealTime()
  32. gametime = getMinecraftTime()
  33. if string.len(realtime) > string.len(gametime) then
  34.     max = string.len(realtime)
  35. else
  36.     max = string.len(gametime)
  37. end
  38. gpu.setResolution(max,2)
  39. gpu.set(1,1,realtime)
  40. gpu.set(1,2,gametime)
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement