Advertisement
Good_Pudge

Nanomachines Control

Aug 26th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.19 KB | None | 0 0
  1. os.execute("pastebin get -f 19rEYzg1 NM")
  2.  
  3. local com = require("component")
  4. local term = require("term")
  5. local gpu = com.gpu
  6. local color = require("colors")
  7. local comp = require("computer")
  8. local modem = com.modem
  9.  
  10. --Сохранение старых настроек--
  11. local OldB = gpu.getBackground()
  12. local OldF = gpu.getForeground()
  13. local OldW,OldH = gpu.getResolution()
  14.  
  15. --Установка новых настроек--
  16. gpu.setResolution(160,42)
  17. gpu.setBackground(color.gray)
  18. gpu.setForeground(color.black)
  19. term.clear()
  20.  
  21. --Объявление функций--
  22. function textbox(x,y,text,colorF,colorB,hex)
  23.     if not hex then
  24.         if colorB ~= nil then
  25.             gpu.setBackground(colorB,true)
  26.         end
  27.  
  28.         if colorF ~= nil then
  29.             gpu.setForeground(colorF,true)
  30.         end
  31.     else
  32.         if colorB ~= nil then
  33.             gpu.setBackground(colorB)
  34.         end
  35.  
  36.         if colorF ~= nil then
  37.             gpu.setForeground(colorF)
  38.         end
  39.     end
  40.  
  41.     term.setCursor(x,y)
  42.     term.write(text)
  43. end
  44.  
  45. function box(x,y,width,heidth,colorB,colorF,hex)
  46.     if not hex then
  47.         if colorB ~= nil then
  48.             gpu.setBackground(colorB,true)
  49.         end
  50.  
  51.         if colorF ~= nil then
  52.             gpu.setForeground(colorF,true)
  53.         end
  54.     else
  55.         if colorB ~= nil then
  56.             gpu.setBackground(colorB)
  57.         end
  58.  
  59.         if colorF ~= nil then
  60.             gpu.setForeground(colorF)
  61.         end
  62.     end
  63.  
  64.     gpu.fill(x,y,width,heidth," ")
  65. end
  66.  
  67. function drawLoadLine(x,y,weight,heidht,Value,colorB)
  68.     gpu.setBackground(color.silver,true)
  69.     gpu.fill(x,y,weight,heidht," ")
  70.    
  71.     gpu.setBackground(colorB,true)
  72.     gpu.fill(x,y,weight/150*Value,heidht," ")
  73. end
  74.  
  75. --Отрисовка статичного интерфейса
  76. textbox(70,1,"Nanomachines Control",color.gray,color.black)
  77. textbox(150,41,"Выйти")
  78.  
  79.  
  80. while true do
  81.     local type,_,sX,sY,button,nick = comp.pullSignal(0)
  82.    
  83.     modem.open(1)
  84.     modem.broadcast(1,"nanomachines","setInput",1,true)
  85.    
  86.     if type == "touch" then
  87.         if sX >= 150 and sX <= 155 then
  88.             if sY > 41 and sY <= 42 then
  89.                 break
  90.             end
  91.         end
  92.     end
  93.    
  94.     if type == "modem_message" then
  95.         textbox(1,3,button,nick)
  96.     end
  97. end
  98.  
  99. --Возвращение старых настроек--
  100. gpu.setBackground(OldB)
  101. gpu.setForeground(OldF)
  102. gpu.setResolution(OldW,OldH)
  103. term.clear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement