Advertisement
4epB9Ik

co.lua

Aug 14th, 2016
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.23 KB | None | 0 0
  1. local component = require('component')
  2. local gpu = component.gpu
  3. local term = require('term')
  4. local math = require('math')
  5. local reactor = component.br_reactor
  6. local storage = component.draconic_rf_storage
  7. local isactive = false
  8. local casinTemp = 0
  9.  
  10. -- Мини настройки
  11. local interval = 0.3 -- интервал между обновлениями
  12.  
  13. gpu.setResolution(90,26)
  14. -- функция прорисовки статичного фона (статичный - значит типо не меняется)
  15. function draw_gui()
  16. gpu.set(1,1,'-')
  17.     gpu.set(90,1,'¬')
  18.     gpu.set(1,26,'L')
  19.     gpu.set(90,26,'-')
  20.     gpu.fill(2,1,88,1,'-') -- верхняя линия
  21.     gpu.fill(2,3,88,1,'-') -- линия под заголовком
  22.     gpu.fill(1,2,1,24,'¦') --левая линия
  23.     gpu.fill(90,2,1,24,'¦') -- правая линия
  24.     gpu.fill(60,2,1,24,'¦') -- средняя линия
  25.     gpu.fill(2,26,88,1,'-') -- нижняя линия
  26.     gpu.set(60,1,'T')
  27.     gpu.set(60,26,'+')
  28.     gpu.set(25,2,'Реактор')
  29.     gpu.set(69,2,'Энергохранилище')
  30.     gpu.set(3,5,'Состояние: ')
  31.     gpu.set(3,7,'Температура обшивки: ')
  32.    
  33. end
  34. function get_info()
  35. isactive = reactor.getActive()                           -- проверка питания реактора
  36. casinTemp = math.floor(reactor.getCasingTemperature())   -- проверка температуры корпуса
  37. gpu.set(21,7,casinTemp..'/2000 °C -->')
  38.     if isactive == true then
  39.         gpu.set(14,5,'Работает')
  40.     else
  41.         gpu.set(14,5,'Выключен')
  42.     end
  43.     if casinTemp > 2000 then
  44.         gpu.set(41,7,'Критическая')
  45.     elseif casinTemp == 0 then
  46.         gpu.set(41,7,'Поиск')
  47.     else
  48.         gpu.set(41,7,'В норме')
  49.     end
  50. end
  51.  
  52. -- Вызов первичной прорисовки (та инфа что у нас не будет меняться в ходе цикла)
  53. draw_gui()
  54. -- основной цикл перезагрузки просчета данных + проверка на возникшие вдруг ошибки..
  55. while (true) do
  56.    
  57.     if pcall(foo) then
  58.     else
  59.     os.sleep(0.3)
  60.     end      
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement