Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- pastebin get -f L6NhAYT7 term.lua
- -- GPU Tier 2, Interner card, Wifi card, Tablet Tier 2
- local component = require("component")
- local computer = require("computer")
- local event = require("event")
- local colors = require("colors")
- local unicode = require("unicode")
- local term = require("term")
- local sides = require("sides")
- local gpu = component.gpu
- local modem = component.modem
- local shell = require("shell")
- a = 0
- shell.execute("oppm install nn")
- term.clear()
- shell.execute("nn init 53453") -- тут менять порт на свой
- ports = 53454 -- и тут и еще ниже в функции 28
- function funcButton1()
- if buttons.button1.buttonPressed == true then
- modem.broadcast(ports,"nanomachines","setInput",1,true)
- else
- modem.broadcast(ports,"nanomachines","setInput",1,false)
- end
- end
- function funcButton2()
- if buttons.button2.buttonPressed == true then
- modem.broadcast(ports,"nanomachines","setInput",2,true)
- else
- modem.broadcast(ports,"nanomachines","setInput",2,false)
- end
- end
- function funcButton3()
- if buttons.button3.buttonPressed == true then
- modem.broadcast(ports,"nanomachines","setInput",3,true)
- else
- modem.broadcast(ports,"nanomachines","setInput",3,false)
- end
- end
- function funcButton4()
- if buttons.button4.buttonPressed == true then
- modem.broadcast(ports,"nanomachines","setInput",4,true)
- else
- modem.broadcast(ports,"nanomachines","setInput",4,false)
- end
- end
- function funcButton5()
- if buttons.button5.buttonPressed == true then
- modem.broadcast(ports,"nanomachines","setInput",5,true)
- else
- modem.broadcast(ports,"nanomachines","setInput",5,false)
- end
- end
- function funcButton6()
- if buttons.button6.buttonPressed == true then
- modem.broadcast(ports,"nanomachines","setInput",6,true)
- else
- modem.broadcast(ports,"nanomachines","setInput",6,false)
- end
- end
- function funcButton7()
- if buttons.button7.buttonPressed == true then
- modem.broadcast(ports,"nanomachines","setInput",7,true)
- else
- modem.broadcast(ports,"nanomachines","setInput",7,false)
- end
- end
- function funcButton8()
- if buttons.button8.buttonPressed == true then
- modem.broadcast(ports,"nanomachines","setInput",8,true)
- else
- modem.broadcast(ports,"nanomachines","setInput",8,false)
- end
- end
- function funcButton9()
- if buttons.button9.buttonPressed == true then
- modem.broadcast(ports,"nanomachines","setInput",9,true)
- else
- modem.broadcast(ports,"nanomachines","setInput",9,false)
- end
- end
- function funcButton10()
- if buttons.button10.buttonPressed == true then
- modem.broadcast(ports,"nanomachines","setInput",10,true)
- else
- modem.broadcast(ports,"nanomachines","setInput",10,false)
- end
- end
- function funcButton11()
- if buttons.button11.buttonPressed == true then
- modem.broadcast(ports,"nanomachines","setInput",11,true)
- else
- modem.broadcast(ports,"nanomachines","setInput",11,false)
- end
- end
- function funcButton12()
- if buttons.button12.buttonPressed == true then
- modem.broadcast(ports,"nanomachines","setInput",12,true)
- else
- modem.broadcast(ports,"nanomachines","setInput",12,false)
- end
- end
- function funcButton13()
- if buttons.button13.buttonPressed == true then
- modem.broadcast(ports,"nanomachines","setInput",13,true)
- else
- modem.broadcast(ports,"nanomachines","setInput",13,false)
- end
- end
- function funcButton14()
- if buttons.button14.buttonPressed == true then
- modem.broadcast(ports,"nanomachines","setInput",14,true)
- else
- modem.broadcast(ports,"nanomachines","setInput",14,false)
- end
- end
- function funcButton15()
- if buttons.button15.buttonPressed == true then
- modem.broadcast(ports,"nanomachines","setInput",15,true)
- else
- modem.broadcast(ports,"nanomachines","setInput",15,false)
- end
- end
- function funcButton16()
- if buttons.button16.buttonPressed == true then
- modem.broadcast(ports,"nanomachines","setInput",16,true)
- else
- modem.broadcast(ports,"nanomachines","setInput",16,false)
- end
- end
- function funcButton17()
- if buttons.button17.buttonPressed == true then
- modem.broadcast(ports,"nanomachines","setInput",17,true)
- else
- modem.broadcast(ports,"nanomachines","setInput",17,false)
- end
- end
- function funcButton18()
- if buttons.button18.buttonPressed == true then
- modem.broadcast(ports,"nanomachines","setInput",18,true)
- else
- modem.broadcast(ports,"nanomachines","setInput",18,false)
- end
- end
- function funcButton19()
- shell.execute("nn test")
- term.clear()
- drawButtons()
- end
- function funcButton20()
- shell.execute("nn get")
- drawButtons()
- end
- function funcButton21()
- shell.execute("nn combo")
- term.clear()
- drawButtons()
- end
- function funcButton22()
- shell.execute("nn getcombo")
- drawButtons()
- end
- function funcButton23()
- shell.execute("nn copy")
- drawButtons()
- end
- function funcButton24()
- shell.execute("nn efon")
- drawButtons()
- end
- function funcButton25()
- shell.execute("nn clear")
- term.clear()
- drawButtons()
- end
- function funcButton26()
- shell.execute("nn reset")
- drawButtons()
- end
- function funcButton27()
- a = 1
- end
- function funcButton28()
- shell.execute("nn init 53454") -- ТУт порт меняй
- term.clear()
- drawButtons()
- print("PORT SET:OK")
- end
- function funcButton29()
- for i = 1, 18 do
- modem.broadcast(ports,"nanomachines","setInput",i,false)
- os.sleep(1)
- end
- print("OFF:OK")
- end
- 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},
- 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},
- 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},
- 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},
- 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},
- 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},
- 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},
- 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},
- 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},
- 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},
- 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},
- 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},
- 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},
- 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},
- 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},
- 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},
- 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},
- 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},
- button19 = {x=48, y=11, text="TEST", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton19, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF},
- button20 = {x=56, y=11, text="GET.T", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton20, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF},
- button21 = {x=64, y=11, text="COMBO", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton21, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF},
- button22 = {x=72, y=11, text="G.COM", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton22, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF},
- button23 = {x=48, y=14, text="COPY", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton23, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF},
- button24 = {x=56, y=14, text="EFFEC", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton24, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF},
- button25 = {x=64, y=14, text="CLEAR", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton25, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF},
- button26 = {x=72, y=14, text="RESET", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton26, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF},
- button27 = {x=72, y=17, text="EXIT", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton27, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF},
- button28 = {x=64, y=17, text="PORT", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton28, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF},
- button29 = {x=56, y=17, text="OFF", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton29, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF}}
- function initButtons()
- for k,v in pairs(buttons) do
- v.width = unicode.wlen(v.text) + 2
- end
- end
- initButtons()
- function drawButtons()
- for k,v in pairs(buttons) do
- if v.active then
- if not v.buttonPressed then -- если кнопка не нажата
- gpu.setForeground(v.cFore)
- gpu.setBackground(v.cBack)
- else -- в ином случае
- gpu.setForeground(v.cFore1)
- gpu.setBackground(v.cBack1)
- end
- gpu.fill(v.x, v.y, v.width, v.height, " ") -- фон для кнопки
- if v.height == 1 then -- если высота кнопки равна 1
- gpu.set(v.x+1, v.y, v.text)
- elseif v.height%2 == 0 then -- если высота кнопки равна четному числу
- gpu.set(v.x+1, v.y + (v.height/2 - 1), v.text)
- elseif v.height%2 == 1 then -- если высота кнопки равна нечетному числу
- gpu.set(v.x+1, v.y + (math.ceil(v.height/2) - 1), v.text)
- end
- if v.autoSwitch == true and v.buttonPressed == true then
- v.buttonPressed = false
- os.sleep(2)
- drawButtons()
- end
- end
- end
- gpu.setForeground(0xFFFFFF)
- gpu.setBackground(0x000000)
- end
- function searchButton()
- while true do
- if a == 1 then
- term.clear()
- break
- end
- local _,_,x,y = event.pull("touch")
- for k,v in pairs(buttons) do
- 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
- if v.switchedButton == true then
- if not v.autoSwitch then
- if v.buttonPressed == false then
- v.buttonPressed = true
- else
- v.buttonPressed = false
- end
- else
- v.buttonPressed = true
- end
- term.clear()
- drawButtons()
- end
- v.func()
- end
- end
- end
- end
- drawButtons()
- searchButton()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement