Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local finished = false
- local wall = 0
- local x = 0
- local z = 0
- local x1 = 0
- local z1 = 0
- function line()
- turtle.select(2)
- if not turtle.detectDown() then
- turtle.placeDown()
- print("block placed")
- end
- if not turtle.detect() then
- turtle.forward()
- print("moving forward")
- if wall == 0 then
- x = x + 1
- else
- x = x - 1
- end
- else
- turtle.select(3)
- if turtle.compare() then
- finished = true
- print("i am finished")
- else
- print("I have reached a wall")
- if wall == 0 then
- turtle.turnRight()
- turtle.forward()
- z = z + 1
- turtle.turnLeft()
- while not turtle.detect() do
- turtle.forward()
- x = x + 1
- end
- print("I have reached the second wall")
- turtle.select(3)
- if turtle.compare() then
- finished = true
- print("i am finished")
- end
- turtle.select(2)
- wall = 1
- turtle.turnRight()
- turtle.turnRight()
- elseif wall == 1 then
- turtle.turnLeft()
- turtle.forward()
- z = z + 1
- turtle.turnRight()
- while not turtle.detect() do
- turtle.forward()
- x = x - 1
- end
- print("I have reached the third wall")
- turtle.select(3)
- if turtle.compare() then
- finished = true
- print("i am finished")
- end
- turtle.select(2)
- wall = 0
- turtle.turnLeft()
- turtle.turnLeft()
- end
- end
- end
- end
- function base()
- if wall == 0 then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- print(z1)
- print(x1)
- while z1 <= 1 do
- turtle.forward()
- z1 = z1 - 1
- end
- turtle.turnLeft()
- while x1 <= 1 do
- turtle.forward()
- x1 = x1 - 1
- end
- turtle.down()
- turtle.suck(2)
- if turtle.getItemCount(2) == 1 then
- print("Welp, no more items, ending.")
- turtle.turnLeft()
- turtle.turnLeft()
- finished = true
- end
- print("returning to work location")
- turtle.up()
- turtle.turnLeft()
- turtle.turnLeft()
- while x1 ~= x do
- turtle.forward()
- x1 = x1 + 1
- end
- turtle.turnRight()
- while z1 ~= z do
- turtle.forward()
- z1 = z1 + 1
- end
- turtle.down()
- if wall == 0 then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- end
- while finished == false do
- if turtle.getItemCount(2) == 1 then
- print("I have run out of blocks")
- -- os.pullevent("turtle_inventory")
- -- print("my inventory has changed, sure hope it was blocks")
- -- print("returning to base")
- -- turtle.up()
- -- z1 = z
- -- x1 = x
- -- base()
- turtle.select(4)
- turtle.transferTo(2)
- turtle.select(5)
- turtle.transferTo(2)
- turtle.select(6)
- turtle.transferTo(2)
- turtle.select(7)
- turtle.transferTo(2)
- turtle.select(8)
- turtle.transferTo(2)
- turtle.select(9)
- turtle.transferTo(2)
- turtle.select(10)
- turtle.transferTo(2)
- turtle.select(11)
- turtle.transferTo(2)
- turtle.select(12)
- turtle.transferTo(2)
- turtle.select(13)
- turtle.transferTo(2)
- turtle.select(14)
- turtle.transferTo(2)
- turtle.select(15)
- turtle.transferTo(2)
- turtle.select(16)
- turtle.transferTo(2)
- turtle.select(2)
- end
- if turtle.getFuelLevel() < 1 then
- turtle.select(1)
- turtle.refuel(1)
- print("I have refueled")
- end
- line()
- print("restarting while loop")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement