Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- miningPlot = {0,0,0}
- -- NO NEGATIVES PLEASE ^ USE BOX FUNCTIOn
- pos = {0,0,0}
- -- +for/back- , -left/Right+ , +Up/Down-
- --Preconditon: chest behind area to min in front
- direction = 0
- -- 0 = ^ , 1 = > , 2 = v , 3 = <,4 = up ,5 down
- function increment(dir)--dir is where going
- if dir == 0 then
- pos[1] = pos[1] + 1
- elseif dir == 1 then
- pos[2] = pos[2] + 1
- elseif dir == 2 then
- pos[1] = pos[1] - 1
- elseif dir == 3 then
- pos[2] = pos[2] - 1
- elseif dir == 4 then
- pos[3] = pos[3] + 1
- elseif dir == 5 then
- pos[3] = pos[3] - 1
- end
- --print(pos[1].." "..pos[2].." "..pos[3])
- end
- function left(x)
- turtle.turnLeft()
- forward(x)
- turtle.turnRight()
- for y=1, x do
- increment(3)
- end
- end
- function right(x)
- turtle.turnRight()
- forward(x)
- turtle.turnLeft()
- for y=1,x do
- increment(1)
- end
- end
- function back(z)
- turtle.turnLeft()
- turtle.turnLeft()
- forward(z)
- turtle.turnRight()
- turtle.turnRight()
- for x=1, z do
- increment(2)
- end
- end
- function forward(dis,real)
- real = real or false
- for i=1, dis do
- turtle.dig()
- turtle.suck()
- turtle.forward()
- if real then
- increment(0)
- end
- end
- end
- function up(dis)
- dis = dis or 1
- for x=1, dis do
- turtle.digUp()
- turtle.suckUp()
- turtle.up()
- increment(4)
- end
- end
- function down(dis)
- dis= dis or 1
- for x=1, dis do
- turtle.digDown()
- turtle.suckDown()
- turtle.down()
- increment(5)
- end
- end
- --precondition: turtle within left lowest corner facing towards to be mined space
- --postcondition: back in positon & direction
- function plane()
- for x=1, miningPlot[1] + 1 do
- if x%2 ~= 0 then
- forward(miningPlot[1],true)
- else
- back(miningPlot[1])
- end
- if pos[1] ~= miningPlot[1] or pos[2] ~= miningPlot[2] then
- right(1)
- end
- end
- returnToOrigin(false)
- end
- --going back to positon
- function returnToOrigin(doY)
- if doY ~= nil or doY == false then
- doY= false
- else
- doY = true
- end
- if pos[1] >0 then
- back(pos[1])
- end
- if pos[2] > 0 then
- left(pos[2])
- end
- if doY and pos[3] > 0 then
- down(pos[3])
- end
- end
- --Carves out a box CORNER to CORNER
- --WARNING gravel & water not yet supported
- --x,y,z are points of corner, other corner is Turtle
- function box(x,y,z)
- miningPlot[1]= x or 7
- miningPlot[2]= z or 7
- miningPlot[3]= y or 4
- for i=0 ,miningPlot[3] do
- plane()
- if i ~= miningPlot[3] then
- up(1)
- end
- end
- returnToOrigin()
- end
- box(2,2,3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement