Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local drone = component.proxy(component.list("drone")())
- local modem = component.proxy(component.list("modem")())
- --Vars
- local port = 12345
- local speed = 1.0
- local col = 0x0000FF
- local user = false
- modem.open(port)
- local pin = tostring(math.random(10000,99999))
- drone.setStatusText(pin)
- --Authorization
- function authoriz(pin)
- local e = {computer.pullSignal()}
- if e[1] == 'modem_message' and pin == e[6] then
- modem.broadcast(port,"ok")
- return e[3]
- else
- modem.broadcast(port, "No")
- end
- end
- while not user do
- user = authoriz(pin)
- end
- drone.setLightColor(col)
- drone.setAcceleration(speed)
- modem.broadcast(port, "|Цвет:" .. col .. "|Скорость: " .. speed .. "|Конец сообщения." )
- while true do
- local e = {computer.pullSignal()}
- if e[1] == 'modem_message' and e[3] == user then
- msg = e[6]
- if msg == 'forward' then
- drone.move(1,0,0)
- elseif msg == "back" then
- drone.move(-1,0,0)
- elseif msg == "left" then
- drone.move(0,0,-1)
- elseif msg == 'right' then
- drone.move(0,0,1)
- elseif msg == "down" then
- drone.move(0,-1,0)
- elseif msg == "up" then
- drone.move(0,1,0)
- elseif msg == "speedUP" then
- speed = speed + 0.5
- modem.broadcast(port, "Скорость изменена: " .. speed)
- drone.setAcceleration(speed)
- elseif msg == "speedDOWN" then
- speed = speed - 0.5
- modem.broadcast(port, "Скорость изменена: " .. speed)
- drone.setAcceleration(speed)
- elseif msg == "color" then
- col = math.random(0x0, 0xFFFFFF)
- drone.setLightColor(col)
- elseif msg == "drop" then
- for i = 1, drone.inventorySize() do
- drone.select(i)
- drone.drop(0)
- end
- elseif msg == "suck" then
- for i = 1,drone.inventorySize() do
- for i = 0, 5 do
- drone.suck(i)
- end
- end
- elseif msg == "info" then
- modem.broadcast(port, "|Цвет:" .. col .. "|Скорость: " .. speed .. "|Конец сообщения." )
- elseif msg == 'PING' then
- modem.broadcast(port,'PONG')
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement