diff --git a/Applications/DroneGrief/Drone.lua b/Applications/DroneGrief/Drone.lua new file mode 100644 index 00000000..40183240 --- /dev/null +++ b/Applications/DroneGrief/Drone.lua @@ -0,0 +1,65 @@ + +local drone = component.proxy(component.list("drone")()) +local modem = component.proxy(component.list("modem")()) +local inventory = component.proxy(component.list("inventory_controller")()) +local port = 512 +local moveSpeed = 1.0 +local suckSide = 0 + +modem.open(port) + +------------------------------------- + +while true do + local e = { computer.pullSignal() } + if e[1] == "modem_message" then + if e[4] == port then + if e[6] == "ECSDrone" then + drone.setStatusText("Команда: " .. e[7]) + if e[7] == "moveUp" then + drone.move(0, moveSpeed, 0) + elseif e[7] == "moveDown" then + drone.move(0, -moveSpeed, 0) + elseif e[7] == "moveForward" then + drone.move(moveSpeed, 0, 0) + elseif e[7] == "moveBack" then + drone.move(-moveSpeed, 0, 0) + elseif e[7] == "moveLeft" then + drone.move(0, 0, -moveSpeed) + elseif e[7] == "moveRight" then + drone.move(0, 0, moveSpeed) + elseif e[7] == "changeColor" then + drone.setLightColor(math.random(0x0, 0xFFFFFF)) + elseif e[7] == "OTSOS" then + for i = 1, (inventory.getInventorySize(0) or 1) do + inventory.suckFromSlot(0, i) + end + for i = 1, (inventory.getInventorySize(1) or 1) do + inventory.suckFromSlot(1, i) + end + elseif e[7] == "VIBROSI" then + for i = 1, drone.inventorySize() do + drone.select(i) + drone.drop(64) + end + elseif e[7] == "moveSpeedUp" then + moveSpeed = moveSpeed + 0.1 + elseif e[7] == "moveSpeedDown" then + moveSpeed = moveSpeed - 0.1 + if moveSpeed < 0.1 then moveSpeed = 0.1 end + end + end + end + end +end + + + + + + + + + + + diff --git a/Applications/DroneGrief/Planshet.lua b/Applications/DroneGrief/Planshet.lua new file mode 100644 index 00000000..72858cc3 --- /dev/null +++ b/Applications/DroneGrief/Planshet.lua @@ -0,0 +1,41 @@ + +local component = require("component") +local modem = component.modem +local event = require("event") +local port = 512 +modem.open(port) + +local keys = { + [17] = "moveForward", + [31] = "moveBack", + [30] = "moveLeft", + [32] = "moveRight", + [42] = "moveDown", + [57] = "moveUp", + [46] = "changeColor", + [18] = "OTSOS", + [16] = "VIBROSI", +} + +while true do + local e = {event.pull()} + if e[1] == "key_down" then + if keys[e[4]] then + print("Команда дрону: " .. keys[e[4]]) + modem.broadcast(port, "ECSDrone", keys[e[4]]) + end + elseif e[1] == "scroll" then + if e[5] == 1 then + modem.broadcast(port, "ECSDrone", "moveSpeedUp") + print("Увеличить скорость перемещения дрона на 0.1") + else + print("Уменьшить скорость перемещения дрона на 0.1") + modem.broadcast(port, "ECSDrone", "moveSpeedDown") + end + end +end + + + + +