Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require("term").clear();
- local cmp=require("component");
- local computer=require("computer");
- local event=require("event");
- local robot;
- local modem;
- local motion,username,userx=0,usery=0,userz=0;
- local port = 512;local key;
- print("Добро пожаловать в систему управления роботом.")
- print("Разработал EliteClubSessions")
- print("Доработал StreamerYT")
- print("\nEnter для продолжения");io.read();require("term").clear()
- print("Компоненты которые поддерживает робот:")
- print("[-] - Не установлен [+] - Установлен\n")
- if cmp.isAvailable("robot") then robot=require("robot");io.write("[+]") else robot=false;io.write("[-]") end;print("Робот")
- if cmp.isAvailable("modem") then modem=cmp["modem"];io.write("[+]") else modem=false;io.write("[-]") end;print("Плата беспроводной сети")
- if cmp.isAvailable("motion_sensor") then motion=cmp["motion_sensor"];io.write("[+]") else motion=false;print("[-]Датчик движения") end
- if robot==false then error("Эта программа предназначена для робота!") end
- if modem==false then error("Плата беспроводной сети обязательна для работы!") end
- print("\nEnter для продолжения");io.read();require("term").clear()
- if motion_sensor!=false then print("Ваш ник:");username=io.read() end
- print('Введите секретный ключ');key = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" .. io.read() .. "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
- require("term").clear()
- print("Ожидание команд!")
- modem.open(port)
- function moveForward()
- robot.forward()
- end
- function moveBack()
- robot.back()
- end
- function moveRight()
- robot.turnRight()
- robot.forward()
- robot.turnLeft()
- end
- function moveLeft()
- robot.turnLeft()
- robot.forward()
- robot.turnRight()
- end
- function moveUp()
- robot.up()
- end
- function moveDown()
- robot.down()
- end
- function moveUser()
- robot.down()
- end
- function moveUserX()
- end
- function moveUserY()
- --+20
- end
- function moveUserZ()
- end
- -------------------------------------------------------------------------------------
- -------------------------------------------------------------------------------------------------------------------------------------
- -------------------------------------------------------------------------------------
- local command = {
- forward = moveForward,
- back = moveBack,
- turnRight = moveRight,
- turnLeft = moveLeft,
- up = moveUp,
- down = moveDown,
- move = moveUser
- }
- local function receive()
- while true do
- local e = { event.pull() }
- if e[1] == "modem_message" and e[4] == port and e[6] == key then
- if command[e[7]] then
- command[e[7]]()
- modem.broadcast(port,key,"power",computer.energy()/(computer.maxEnergy()/100))
- ----modem.broadcast( port , key , 1 , 2 , 3 , 4 , 5 , 6 , 7 )
- ---- (e[1] ,e[2] ,e[3] ,e[4] ,e[5] ,e[6] ,e[7] ,e[8] ,e[9] ,e[10] ,e[11] ,e[12] ,e[13] )
- ---- (mm_me,mmget,mmput, blocks )
- end
- elseif e[1]=="motion" and e[6] == username then
- userx=math.ceil(t[3]);
- usery=math.ceil(t[4])+2;
- userz=math.ceil(t[5]);
- end
- end
- end
- receive()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement