Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require "component"
- local computer = require "computer"
- local term = require "term"
- local robot = require "robot"
- local sides = require "sides"
- local energy = computer.energy()
- local function detect(type, direction) --Обнаружение определенноо типа [направления] роботом. Возвращает boolean.
- local detection
- if direction == "up" then detection = select(2, robot.detectUp())
- elseif direction == "down" then detection = select(2, robot.detectDown())
- else
- detection = select(2, robot.detect())
- end
- if detection == type then
- return true
- end
- end
- local function checkEnergy() --TODO
- end
- local function killLiquid(slot) -- Удаление всех жидкостей и замена на блоки вокруг робота, исключая зад
- local types = {"liquid", "replaceable"}
- robot.select(slot)
- local function placeOnLiquid(direction) -- Замена жидкости на блок в слоте, если есть жидкость
- for _, type in pairs(types) do
- if detect(type,direction) then
- if direction == "up" then
- robot.placeUp()
- elseif direction == "down"then
- robot.placeDown()
- else robot.place()
- end
- end
- end
- end
- placeOnLiquid("up")
- placeOnLiquid("down")
- placeOnLiquid()
- robot.turnRight()
- placeOnLiquid()
- robot.turnAround()
- placeOnLiquid()
- robot.turnRight()
- end
- local function robotTunnel(numSteps, height) --REFACTOR!!!
- local function line()
- for i = 1, numSteps do
- if detect("solid") then robot.swing() end
- robot.forward()
- for i = 1, height-1 do
- if detect("solid","up") then robot.swingUp() end
- robot.up()
- end
- for i = 1, height-1 do
- robot.down()
- end
- end
- end
- line()
- robot.turnAround()
- line()
- robot.turnAround()
- end
- term.clear()
- term.write("Введите длинну тоннеля \n")
- LENGTH = term.read()
- robotTunnel(LENGTH,1)
- print('Energy: '..energy - computer.energy())
Add Comment
Please, Sign In to add comment