BruceWplays

GLTime V1

Jan 12th, 2023
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local sizemul = 1
  2.  
  3.  
  4.  
  5. local txthi = 2
  6.  
  7.  
  8.  
  9. local widsize = 80
  10. local hisize = 10
  11.  
  12. hisize = hisize * txthi
  13. local dedwid = 2
  14. local dedhi = 5
  15.  
  16. os.loadAPI("AndysPrograms/gltime/api/getmnth")
  17.  
  18. local mineminute = 60 / 72
  19. mineminute = mineminute * 0.999
  20. local sizediv = 1
  21. widsize = widsize / sizediv
  22. hisize = hisize / sizediv
  23. local scaletsize = sizemul / sizediv
  24.  
  25. local canvas = peripheral.wrap("back").canvas()
  26. canvas.clear() -- Get rid of our previous clock
  27.  
  28. local group = canvas.addGroup({ 0, 0 })
  29.  
  30. -- Look, we add items to our group instead
  31. --group.addRectangle(0, 0, widsize, hisize, 0xFF000064)
  32.  
  33. local text = group.addText({ 5, 5 }, "")
  34. local text2 = group.addText({ 5, 5 }, "")
  35. text.setScale(scaletsize)
  36. text.setColour(255,1,255)
  37.  
  38. local x, y, dx, dy = 0, 0, 5, 5
  39.  
  40. -- Compute the dimensions we can move within
  41. local width, height = canvas.getSize()
  42. width = width - widsize
  43. height = height - hisize
  44. width = width - dedwid
  45. height = height - dedhi
  46. y = height
  47. while true do
  48.     time_st = os.epoch()
  49.  
  50.     local _, day, month, _ = getmnth.getmnth()
  51.     print(os.epoch())
  52.     group.setPosition(x, y)
  53.  
  54.     if true then
  55.         otftim2 = string.gsub(textutils.formatTime( os.time(), true ), ":", "")
  56.         --print(otftim2)
  57.         --print(tonumber(otftim2))
  58.         if tonumber(otftim2) >= 1600 and tonumber(otftim2) < 1800 then
  59.             text.setColour(252, 136, 3)
  60.         elseif tonumber(otftim2) >= 1800 and tonumber(otftim2) <= 2359 then
  61.             text.setColour(191, 72, 61)
  62.  
  63.         elseif tonumber(otftim2) >= 0 and tonumber(otftim2) <= 600 then
  64.             text.setColour(191, 72, 61)
  65.         else
  66.             text.setColour(255, 255, 255)
  67.         end
  68.  
  69.     end
  70.     -- And update the time
  71.  
  72.     time_nospace_zero = string.gsub(textutils.formatTime(os.time(), false), " ", " ")  
  73.     time_nospace_10error = string.gsub(time_nospace_zero, "0:", "12:")
  74.     time_nospace = string.gsub(time_nospace_10error, "112:", "10:")
  75.  
  76.     text.setText(time_nospace)
  77.     text2.setText("\n"..day.." "..month)
  78.     if time_en == nil then
  79.         time_sub = 0
  80.     end
  81.     mineminute = 60 / 72
  82.     time_en = os.epoch()
  83.     time_sub = time_en - time_st
  84.     if time_sub < 0 then
  85.         time_sub = time_sub / -1
  86.     end
  87.     mineminute = mineminute - (time_sub / 1000)
  88.     sleep(mineminute)
  89. end
Add Comment
Please, Sign In to add comment