Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local computer = require("computer")
- local gpu = component.gpu
- local modem = component.proxy(component.list('modem')())
- local window = ""
- local port = 467
- function split(z,x);if x==nil then;x="%s";end;local t={};for v in string.gmatch(z,"([^"..x.."]+)") do;table.insert(t,v);end;return t;end;
- local robot = "local robot=require('robot');"
- local drone = "local drone=component.proxy(component.list('drone')());"
- function eval(d)
- modem.broadcast(port,d)
- end
- function gui()
- gpu.setResolution(80,25)
- fill(1,1,80,1,0x000000,0x000000," ") -- panel
- fill(1,2,80,25,0x42aaff,0x000000," ") -- app
- end
- function info()
- window = "info"
- gui()
- set(66,3,0x42aaff,0xffffff,"UUID: " .. split(modem.address,"-")[1])
- set(2,3,0x42aaff,0xffffff,"Закрыть приложение: Ctrl + Alt + C")
- set(2,4,0x42aaff,0xffffff,"Справка: F1 (Вы здесь!)")
- set(2,5,0x42aaff,0xffffff,"Меню: F3")
- set(2,6,0x42aaff,0xffffff,"Минимизировать окно: F4")
- end
- function menu()
- window = "menu"
- gui()
- end
- function minimize()
- window = "minimize"
- gpu.setResolution(1,1)
- end
- function keytest()
- window = "keytest"
- gpu.setResolution(8,2)
- end
- function fill(x,y,w,h,cb,cf,t) gpu.setBackground(cb);gpu.setForeground(cf);gpu.fill(x,y,w,h,t) end
- function set(x,y,cb,cf,t) gpu.setBackground(cb);gpu.setForeground(cf);gpu.set(x,y,t) end
- info()
- local bot = {}
- function bot.forward(); eval(robot.."robot.forward()") ;end
- function bot.back(); eval(robot.."robot.back()") ;end
- function bot.left(); eval(robot.."robot.turnLeft()") ;end
- function bot.right(); eval(robot.."robot.turnRight()") ;end
- function bot.up(); eval(robot.."robot.up()") ;end
- function bot.down(); eval(robot.."robot.down()") ;end
- while true do
- local event, screen_uuid, ascii, id, username = computer.pullSignal()
- if event == "key_up" then
- if id == 59 then info()
- elseif id == 61 then menu()
- elseif id == 62 then minimize()
- elseif id == 88 then keytest()
- elseif id == 41 then
- elseif (window == "menu" or window == "minimize") then
- if id == 17 then bot.forward()
- elseif id == 31 then bot.back()
- elseif id == 30 then bot.left()
- elseif id == 32 then bot.right()
- elseif id == 57 then bot.up()
- elseif id == 42 then bot.down()
- elseif id == 72 then eval(robot.."robot.swingUp()")
- elseif id == 76 then eval(robot.."robot.swing()")
- elseif id == 80 then eval(robot.."robot.swingDown()")
- elseif id == 13 then eval("movetarget = '"..username.."'")
- elseif id == 12 then eval("movetarget = nil")
- elseif id == 50 then
- eval(robot.."for q = 1, 10 do;for w = 1, 10 do;robot.swing();robot.swingUp();robot.swingDown();robot.forward();end;for e = 1, 2 do;robot.turnLeft();robot.swing();robot.swingUp();robot.swingDown();robot.forward();end;for r = 1, 10 do;robot.swing();robot.swingUp();robot.swingDown();robot.forward();end;for t = 1, 2 do;robot.turnRight();robot.swing();robot.swingUp();robot.swingDown();robot.forward();end;end;")
- else
- end
- end
- if window == "keytest" then
- print("key: " .. id)
- end
- end
- end
Add Comment
Please, Sign In to add comment