Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- modem = peripheral.wrap("right")
- function cycle(length)
- turtle.turnLeft()
- digBranch(length)
- turtle.turnRight()
- turtle.turnRight()
- digBranch(length)
- turtle.turnLeft()
- seekOre()
- storeItems()
- forward()
- forward()
- forward()
- end
- function digBranch(length)
- for i = 1, length do
- digOnce()
- end
- for i = 1, length do
- back()
- end
- end
- function digOnce()
- forward()
- seekOre()
- end
- function seekOre()
- local r = 0
- turtle.select(1)
- tryStoreItems()
- if turtle.detectUp() then
- if not compareUp() then
- up()
- seekOre()
- down()
- end
- end
- if turtle.detectDown() then
- if not compareDown() then
- down()
- seekOre()
- up()
- end
- end
- for i = 1, 4 do
- turtle.turnRight()
- if turtle.detect() and not compare() then
- forward()
- seekOre()
- back()
- end
- end
- end
- function compareUp()
- matches = false
- turtle.select(1)
- matches = matches or turtle.compareUp()
- turtle.select(2)
- matches = matches or turtle.compareUp()
- turtle.select(3)
- matches = matches or turtle.compareUp()
- return matches
- end
- function compareDown()
- matches = false
- turtle.select(1)
- matches = matches or turtle.compareDown()
- turtle.select(2)
- matches = matches or turtle.compareDown()
- turtle.select(3)
- matches = matches or turtle.compareDown()
- return matches
- end
- function compare()
- matches = false
- turtle.select(1)
- matches = matches or turtle.compare()
- turtle.select(2)
- matches = matches or turtle.compare()
- turtle.select(3)
- matches = matches or turtle.compare()
- return matches
- end
- function tryStoreItems()
- store = false
- for i = 4, 15 do
- if turtle.getItemSpace(i) < 4 then
- store = true
- end
- end
- if store then
- storeItems()
- end
- end
- function storeItems()
- turtle.digUp()
- turtle.select(16)
- turtle.placeUp()
- for i = 4, 15 do
- turtle.select(i)
- turtle.dropUp(turtle.getItemCount())
- end
- turtle.select(16)
- turtle.digUp()
- end
- function dig()
- while true do
- turtle.dig()
- os.sleep(0.2)
- if not turtle.detect() then
- break
- end
- end
- end
- function digUp()
- while true do
- turtle.digUp()
- os.sleep(0.2)
- if not turtle.detectUp() then
- break
- end
- end
- end
- function forward()
- while true do
- if turtle.forward() then
- return
- else
- print"obstructed in: forward"
- dig()
- turtle.attack()
- turtle.attack()
- turtle.attack()
- end
- end
- end
- function back()
- while true do
- if turtle.back() then
- return
- else
- print"obstructed in: back"
- turtle.turnRight()
- turtle.turnRight()
- dig()
- kill()
- turtle.turnRight()
- turtle.turnRight()
- end
- end
- end
- function kill()
- loop = true
- while loop do
- loop = turtle.attack()
- if loop then
- os.sleep(1)
- end
- end
- end
- function killUp()
- loop = true
- while loop do
- loop = turtle.attackUp()
- if loop then
- os.sleep(1)
- end
- end
- end
- function killDown()
- loop = true
- while loop do
- loop = turtle.attackDown()
- if loop then
- os.sleep(1)
- end
- end
- end
- function up()
- while true do
- if turtle.up() then
- return
- else
- print"obstructed in: up"
- digUp()
- killUp()
- end
- end
- end
- function down()
- while true do
- if turtle.down() then
- return
- else
- print"obstructed in: down"
- turtle.digDown()
- killDown()
- end
- end
- end
- function grid(depth, side, length, layers)
- layers = layers or 1
- for l = 1, layers do
- for s = 1, side do
- for i = 1, depth do
- cycle(length)
- end
- print"waiting..."
- print"ok."
- for i = 1, depth do
- back()
- back()
- back()
- end
- print"waiting..."
- print"ok."
- if s < side then
- turtle.turnRight()
- for i = 1, length * 2 + 1 do
- forward()
- end
- turtle.turnLeft()
- end
- end
- turtle.turnLeft()
- for s = 2, side do
- for i = 1, length * 2 + 1 do
- forward()
- end
- end
- turtle.turnRight()
- if l < layers then
- up()
- up()
- end
- end
- for i = 2, layers do
- down()
- down()
- end
- end
- grid(2, 1, 4, 2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement