Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local robot = require("robot")
- local computer = require("computer")
- local component = require("component")
- local sides = require("sides")
- function moveForward()
- if robot.detect() then robot.swing() end
- if not robot.forward() then computer.shutdown() end
- end
- function moveUp()
- if robot.detectUp() then robot.swingUp() end
- if not robot.up() then computer.shotdown() end
- end
- function moveDown()
- if robot.detectDown() then robot.swingDown() end
- if not robot.down() then computer.shutdown() end
- end
- function shouldMine(side)
- local info = component.geolyzer.analyze(side)
- return info and info.name and (info.name:match(".*[oO]re.*") or info.name:match(".*Obsidian.*"))
- end
- function scanDig()
- if robot.detectUp() and shouldMine(sides.top) then
- moveUp()
- scanDig()
- moveDown()
- end
- if robot.detectDown() and shouldMine(sides.bottom) then
- moveDown()
- scanDig()
- moveUp()
- end
- for i=2,5,1 do
- if robot.detect() and shouldMine(i) then
- if i == sides.right then robot.turnRight()
- elseif i == sides.left then robot.turnLeft()
- elseif i == sides.back then robot.turnAround()
- end
- moveForward()
- scanDig()
- robot.back()
- if i == sides.right then robot.turnLeft()
- elseif i == sides.left then robot.turnRight()
- elseif i == sides.back then robot.turnAround()
- end
- end
- end
- end
- local distance = 10
- for ix=1,distance/2,1 do
- scanDig()
- moveUp()
- scanDig()
- moveForward()
- scanDig()
- moveDown()
- scanDig()
- moveForward()
- end
- robot.turnAround()
- for i=1,distance,1 do
- moveForward()
- end
- computer.shutdown()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement