Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- direction=1
- floors=25
- rows=25
- blocks=25
- x=0
- y=0
- z=0
- function turnLeft()
- position(-1)
- turtle.turnLeft()
- end
- function turnRight()
- position(1)
- turtle.turnRight()
- end
- function dig()
- while turtle.detect() == true do
- turtle.attack()
- turtle.dig()
- os.sleep(0.5)
- end
- end
- function digUp()
- while turtle.detectUp() == true do
- turtle.digUp()
- os.sleep(0.5)
- end
- end
- function digDown()
- while turtle.detectDown() == true do
- turtle.digDown()
- os.sleep(0.5)
- end
- end
- function down(times)
- if times==nil then times=1 end
- for i=1,times do
- turtle.digDown()
- turtle.down()
- turtle.digDown()
- turtle.down()
- turtle.digDown()
- turtle.down()
- z=z-1
- end
- end
- function up(times)
- if times == nil then times=1 end
- for i=1,times do
- digUp()
- turtle.up()
- digUp()
- turtle.up()
- digUp()
- turtle.up()
- z=z+1
- end
- end
- function forward(times)
- if times == nil then times=1 end
- for i=1, times do
- dig()
- turtle.forward()
- if direction == 1 then x=x-1 elseif
- direction == 2 then y=y+1 elseif
- direction == 3 then x=x+1 elseif
- direction == 4 then y=y-1 end
- end
- end
- function position(x,h)
- if x<0 then
- if direction == 1 then
- direction = 4
- else
- direction = direction - 1
- end
- elseif x>0 then
- if direction == 4 then
- direction = 1
- else
- direction = direction + 1
- end
- end
- end
- function default_direction()
- while direction > 1 do
- turnLeft()
- end
- end
- function drop()
- for i=2,16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(1)
- end
- function spaceAviable()
- turtle.select(15)
- if turtle.getItemDetail() then
- return false
- else
- turtle.select(1)
- return true
- end
- end
- function checkChest()
- turtle.select(1)
- if turtle.compare() == false then
- dig()
- digUp()
- forward()
- digUp()
- turnLeft()
- turnLeft()
- forward()
- turnLeft()
- turnLeft()
- turtle.place()
- end
- turnLeft()
- forward()
- turnRight()
- if turtle.compare() == false then
- dig()
- digUp()
- forward()
- digUp()
- turnLeft()
- turnLeft()
- forward()
- turnLeft()
- turnLeft()
- turtle.place()
- end
- turnRight()
- forward()
- turnLeft()
- end
- function emptyTurtle(finish, start)
- if spaceAviable() and finish==nil then
- return false
- else
- local curx=x
- local cury=y
- local curz=z
- default_direction()
- if start == nil or start == false then
- if finish == true then
- up(-z)
- end
- end
- forward(x)
- turnLeft()
- forward(y)
- default_direction()
- checkChest()
- drop()
- if finish==nil or finish==false then
- turnRight()
- forward(cury)
- turnRight()
- forward(curx)
- turnLeft()
- down(-curz)
- end
- if start==true then
- turnRight()
- forward(cury)
- -- down(-curz)
- end
- end
- end
- turnRight()
- forward(2)
- for h=1, floors do
- for i=1, rows do
- for j=1, blocks do
- emptyTurtle()
- dig()
- digUp()
- digDown()
- forward()
- digUp()
- digDown()
- end
- turnLeft()
- turnLeft()
- for j=1, blocks do
- dig()
- forward()
- end
- if i~=rows then
- turnLeft()
- dig()
- forward()
- digUp()
- turnLeft()
- end
- end
- if h~=floors then
- emptyTurtle(true, true)
- down()
- end
- end
- emptyTurtle(true)
- term.write(direction)
- term.write(" ")
- term.write('x: ')
- term.write(x)
- term.write(' y: ')
- term.write(y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement