Advertisement
danya201272

[OpenComputers]Nanits TERM

Nov 1st, 2022 (edited)
1,083
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.71 KB | Source Code | 0 0
  1. -- pastebin get -f L6NhAYT7 term.lua
  2. -- GPU Tier 2, Interner card, Wifi card, Tablet Tier 2
  3. local component = require("component")
  4. local computer = require("computer")
  5. local event = require("event")
  6. local colors = require("colors")
  7. local unicode = require("unicode")
  8. local term = require("term")
  9. local sides = require("sides")
  10. local gpu = component.gpu
  11. local modem = component.modem
  12. local shell = require("shell")
  13. a = 0
  14. shell.execute("oppm install nn")
  15. term.clear()
  16. shell.execute("nn init 53453") -- тут менять порт на свой
  17. ports = 53454 -- и тут и еще ниже в функции 28
  18. function funcButton1()
  19. if buttons.button1.buttonPressed == true then
  20. modem.broadcast(ports,"nanomachines","setInput",1,true)
  21. else
  22. modem.broadcast(ports,"nanomachines","setInput",1,false)
  23. end
  24. end
  25. function funcButton2()
  26. if buttons.button2.buttonPressed == true then
  27. modem.broadcast(ports,"nanomachines","setInput",2,true)
  28. else
  29. modem.broadcast(ports,"nanomachines","setInput",2,false)
  30. end
  31. end
  32. function funcButton3()
  33. if buttons.button3.buttonPressed == true then
  34. modem.broadcast(ports,"nanomachines","setInput",3,true)
  35. else
  36. modem.broadcast(ports,"nanomachines","setInput",3,false)
  37. end
  38. end
  39. function funcButton4()
  40. if buttons.button4.buttonPressed == true then
  41. modem.broadcast(ports,"nanomachines","setInput",4,true)
  42. else
  43. modem.broadcast(ports,"nanomachines","setInput",4,false)
  44. end
  45. end
  46. function funcButton5()
  47. if buttons.button5.buttonPressed == true then
  48. modem.broadcast(ports,"nanomachines","setInput",5,true)
  49. else
  50. modem.broadcast(ports,"nanomachines","setInput",5,false)
  51. end
  52. end
  53. function funcButton6()
  54. if buttons.button6.buttonPressed == true then
  55. modem.broadcast(ports,"nanomachines","setInput",6,true)
  56. else
  57. modem.broadcast(ports,"nanomachines","setInput",6,false)
  58. end
  59. end
  60. function funcButton7()
  61. if buttons.button7.buttonPressed == true then
  62. modem.broadcast(ports,"nanomachines","setInput",7,true)
  63. else
  64. modem.broadcast(ports,"nanomachines","setInput",7,false)
  65. end
  66. end
  67. function funcButton8()
  68. if buttons.button8.buttonPressed == true then
  69. modem.broadcast(ports,"nanomachines","setInput",8,true)
  70. else
  71. modem.broadcast(ports,"nanomachines","setInput",8,false)
  72. end
  73. end
  74. function funcButton9()
  75. if buttons.button9.buttonPressed == true then
  76. modem.broadcast(ports,"nanomachines","setInput",9,true)
  77. else
  78. modem.broadcast(ports,"nanomachines","setInput",9,false)
  79. end
  80. end
  81. function funcButton10()
  82. if buttons.button10.buttonPressed == true then
  83. modem.broadcast(ports,"nanomachines","setInput",10,true)
  84. else
  85. modem.broadcast(ports,"nanomachines","setInput",10,false)
  86. end
  87. end
  88. function funcButton11()
  89. if buttons.button11.buttonPressed == true then
  90. modem.broadcast(ports,"nanomachines","setInput",11,true)
  91. else
  92. modem.broadcast(ports,"nanomachines","setInput",11,false)
  93. end
  94. end
  95. function funcButton12()
  96. if buttons.button12.buttonPressed == true then
  97. modem.broadcast(ports,"nanomachines","setInput",12,true)
  98. else
  99. modem.broadcast(ports,"nanomachines","setInput",12,false)
  100. end
  101. end
  102. function funcButton13()
  103. if buttons.button13.buttonPressed == true then
  104. modem.broadcast(ports,"nanomachines","setInput",13,true)
  105. else
  106. modem.broadcast(ports,"nanomachines","setInput",13,false)
  107. end
  108. end
  109. function funcButton14()
  110. if buttons.button14.buttonPressed == true then
  111. modem.broadcast(ports,"nanomachines","setInput",14,true)
  112. else
  113. modem.broadcast(ports,"nanomachines","setInput",14,false)
  114. end
  115. end
  116. function funcButton15()
  117. if buttons.button15.buttonPressed == true then
  118. modem.broadcast(ports,"nanomachines","setInput",15,true)
  119. else
  120. modem.broadcast(ports,"nanomachines","setInput",15,false)
  121. end
  122. end
  123. function funcButton16()
  124. if buttons.button16.buttonPressed == true then
  125. modem.broadcast(ports,"nanomachines","setInput",16,true)
  126. else
  127. modem.broadcast(ports,"nanomachines","setInput",16,false)
  128. end
  129. end
  130. function funcButton17()
  131. if buttons.button17.buttonPressed == true then
  132. modem.broadcast(ports,"nanomachines","setInput",17,true)
  133. else
  134. modem.broadcast(ports,"nanomachines","setInput",17,false)
  135. end
  136. end
  137. function funcButton18()
  138. if buttons.button18.buttonPressed ==  true then
  139. modem.broadcast(ports,"nanomachines","setInput",18,true)
  140. else
  141. modem.broadcast(ports,"nanomachines","setInput",18,false)
  142. end
  143. end
  144. function funcButton19()
  145. shell.execute("nn test")
  146. term.clear()
  147. drawButtons()
  148. end
  149. function funcButton20()
  150. shell.execute("nn get")
  151. drawButtons()
  152. end
  153. function funcButton21()
  154.  shell.execute("nn combo")
  155.  term.clear()
  156.  drawButtons()
  157. end
  158. function funcButton22()
  159.  shell.execute("nn getcombo")
  160.  drawButtons()
  161. end
  162. function funcButton23()
  163. shell.execute("nn copy")
  164. drawButtons()
  165. end
  166. function funcButton24()
  167. shell.execute("nn efon")
  168. drawButtons()
  169. end
  170. function funcButton25()
  171. shell.execute("nn clear")
  172. term.clear()
  173. drawButtons()
  174. end
  175. function funcButton26()
  176. shell.execute("nn reset")
  177. drawButtons()
  178. end
  179. function funcButton27()
  180. a = 1
  181. end
  182. function funcButton28()
  183. shell.execute("nn init 53454") -- ТУт порт меняй
  184. term.clear()
  185. drawButtons()
  186. print("PORT SET:OK")
  187. end
  188. function funcButton29()
  189. for i = 1, 18 do
  190. modem.broadcast(ports,"nanomachines","setInput",i,false)
  191. os.sleep(1)
  192. end
  193. print("OFF:OK")
  194. end
  195. buttons = {button1 = {x=48, y=2, text=".1", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton1, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00},
  196.            button2 = {x=53, y=2, text=".2", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton2, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00},
  197.            button3 = {x=58, y=2, text=".3", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton3, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00},
  198.            button4 = {x=63, y=2, text=".4", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton4, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00},
  199.            button5 = {x=68, y=2, text=".5", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton5, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00},
  200.            button6 = {x=73, y=2, text=".6", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton6, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00},
  201.            button7 = {x=48, y=5, text=".7", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton7, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00},
  202.            button8 = {x=53, y=5, text=".8", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton8, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00},
  203.            button9 = {x=58, y=5, text=".9", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton9, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00},
  204.            button10 = {x=63, y=5, text="10", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton10, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00},
  205.            button11 = {x=68, y=5, text="11", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton11, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00},
  206.            button12 = {x=73, y=5, text="12", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton12, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00},
  207.            button13 = {x=48, y=8, text="13", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton13, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00},
  208.            button14 = {x=53, y=8, text="14", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton14, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00},
  209.            button15 = {x=58, y=8, text="15", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton15, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00},
  210.            button16 = {x=63, y=8, text="16", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton16, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00},
  211.            button17 = {x=68, y=8, text="17", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton17, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00},
  212.            button18 = {x=73, y=8, text="18", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton18, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00},
  213.            button19 = {x=48, y=11, text="TEST", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton19, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF},
  214.            button20 = {x=56, y=11, text="GET.T", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton20, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF},
  215.            button21 = {x=64, y=11, text="COMBO", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton21, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF},
  216.            button22 = {x=72, y=11, text="G.COM", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton22, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF},
  217.            button23 = {x=48, y=14, text="COPY", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton23, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF},
  218.            button24 = {x=56, y=14, text="EFFEC", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton24, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF},
  219.            button25 = {x=64, y=14, text="CLEAR", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton25, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF},
  220.            button26 = {x=72, y=14, text="RESET", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton26, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF},
  221.            button27 = {x=72, y=17, text="EXIT", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton27, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF},
  222.            button28 = {x=64, y=17, text="PORT", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton28, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF},
  223.            button29 = {x=56, y=17, text="OFF", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton29, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF}}
  224. function initButtons()
  225. for k,v in pairs(buttons) do
  226. v.width = unicode.wlen(v.text) + 2
  227. end
  228. end
  229. initButtons()
  230. function drawButtons()
  231.  
  232. for k,v in pairs(buttons) do
  233. if v.active then
  234. if not v.buttonPressed then -- если кнопка не нажата
  235. gpu.setForeground(v.cFore)
  236. gpu.setBackground(v.cBack)
  237. else                      -- в ином случае
  238. gpu.setForeground(v.cFore1)
  239. gpu.setBackground(v.cBack1)
  240. end
  241. gpu.fill(v.x, v.y, v.width, v.height, " ") -- фон для кнопки
  242. if v.height == 1 then         -- если высота кнопки равна 1
  243. gpu.set(v.x+1, v.y, v.text)
  244. elseif v.height%2 == 0 then   -- если высота кнопки равна четному числу
  245. gpu.set(v.x+1, v.y + (v.height/2 - 1), v.text)
  246. elseif v.height%2 == 1 then   -- если высота кнопки равна нечетному числу
  247. gpu.set(v.x+1, v.y + (math.ceil(v.height/2) - 1), v.text)
  248. end
  249. if v.autoSwitch == true and v.buttonPressed == true then
  250. v.buttonPressed = false
  251. os.sleep(2)
  252. drawButtons()
  253. end
  254. end
  255. end
  256. gpu.setForeground(0xFFFFFF)
  257. gpu.setBackground(0x000000)
  258. end
  259.  
  260. function searchButton()
  261.  
  262. while true do
  263. if a == 1 then
  264. term.clear()
  265. break
  266. end
  267. local _,_,x,y = event.pull("touch")
  268. for k,v in pairs(buttons) do
  269. if x >= v.x and x < v.x + v.width+2 and y >= v.y and y < v.y + v.height and v.active then
  270. if v.switchedButton == true then
  271. if not v.autoSwitch then
  272. if v.buttonPressed == false then
  273. v.buttonPressed = true
  274. else
  275. v.buttonPressed = false
  276. end
  277. else
  278. v.buttonPressed = true
  279. end
  280. term.clear()
  281. drawButtons()
  282. end
  283. v.func()
  284. end
  285. end
  286. end
  287.  
  288. end
  289.  
  290. drawButtons()
  291. searchButton()
Tags: GTCE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement