Asioron

Graf_drawer

Dec 12th, 2018
166
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -------------------------------------------------------
  2. --        Программа График для Storage drawers       --
  3. --        для компьютеров из мода OpenComputers      --
  4. --          проект http://computercraft.ru           --
  5. --                  Version 0.1                      --
  6. --                 2018, © Asior                     --
  7. -------------------------------------------------------
  8.  
  9. local c = require("component")
  10. local drawer = nil
  11. if component.isAvailable("drawer") then
  12.   drawer = c.drawer
  13. else
  14.   print('Подключите адаптер к бочке!')
  15.   os.exit()
  16. end
  17. local term = require("term")
  18. local gpu = c.gpu
  19. local charts = require("charts")
  20. gpu.setResolution(50, 16)
  21.  
  22. local container = charts.Container()
  23. local payload = charts.Histogram()
  24. payload.max = drawer.getMaxCapacity(1)
  25. payload.min = 0
  26. payload.align = charts.sides.RIGHT
  27. container.x = 1
  28. container.y = 3
  29. container.width = 50
  30. container.height = 14
  31. payload.colorFunc = function(index, norm, value, self, container)
  32.   return 0x20ff20
  33. end
  34. container.payload = payload
  35.  
  36. local name = ''
  37. local count = -1
  38.  
  39. while true do
  40.   if count ~= drawer.getItemCount(1) then
  41.     count = drawer.getItemCount(1)
  42.     term.clear()
  43.     if drawer.getStackInSlot(2) then
  44.       name = drawer.getStackInSlot(2).display_name
  45.     else
  46.       name = 'Пустота'
  47.     end
  48.     gpu.set(1,1,'Хранится: '..name)
  49.     gpu.set(1,2,'Объем: '..drawer.getItemCount(1)..'/'..drawer.getMaxCapacity(1))
  50.     table.insert(payload.values, drawer.getItemCount(1))
  51.     container:draw()
  52.   end
  53.   os.sleep(1)
  54. end
RAW Paste Data