Advertisement
QuicksilverBoy

Clock alpha

Feb 28th, 2017
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.56 KB | None | 0 0
  1. --pastebin get HEUWNFEW numAPI.lua
  2.  
  3. --массив {card:string, monitor:string}
  4. clock = {"35f", "49f"}
  5. color1 = 0xFF0000 --цвет когда включен
  6. color2 = 0x222222 --цвет когда выключен
  7.  
  8. numAPI = require("numAPI")
  9. os = require("os")
  10. math = require("math")
  11. component = require("component")
  12. event = require("event")
  13.  
  14. --getRS = component.redstone.getInput
  15.  
  16. gpu = component.proxy(component.get(clock[1]))
  17. gpu.bind(component.get(clock[2]))
  18.  
  19. gpu.setResolution(48, 13)
  20.  
  21. timeDisplay = {
  22.     --часы
  23.     h1 = numAPI.createNum(14, 1, 4, color1, color2, clock[1]),
  24.     h2 = numAPI.createNum(4, 1, 4, color1, color2, clock[1]),
  25.     --минуты
  26.     m1 = numAPI.createNum(37, 1, 4, color1, color2, clock[1]),
  27.     m2 = numAPI.createNum(27, 1, 4, color1, color2, clock[1]),
  28. }
  29.  
  30. xr, yr = gpu.getResolution()
  31.  
  32. gpu.fill(1, 1, xr, yr, ' ')
  33.  
  34. function redraw()
  35.     for t in pairs(timeDisplay) do
  36.         timeDisplay[t]:drawNum()
  37.     end
  38. end
  39.  
  40. function setClock(t)
  41.     local ttt = {
  42.         h = math.floor(t / 60 / 60 + 1) % 24,
  43.         m = math.floor(t / 60) % 60,
  44.     }
  45.  
  46.     for cl in pairs(ttt) do
  47.         local fh = math.floor(ttt[cl] / 10)
  48.         local h = ttt[cl] - (fh * 10)
  49.         timeDisplay[cl .. '2']:setNumber(fh)
  50.         timeDisplay[cl .. '1']:setNumber(h)
  51.     end
  52. end
  53.  
  54. gpu.setBackground(color1)
  55. gpu.set(24, 9, ' ', true)
  56. gpu.set(24, 5, ' ', true)
  57. gpu.setBackground(0)
  58.  
  59. secT = 0
  60.  
  61. while true do
  62.     os.sleep(1/20)
  63.     timeOS = os.time()
  64.     secT = secT + (1 / 20)
  65.  
  66.     setClock(timeOS)
  67.  
  68.     redraw()
  69. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement