Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- distanceFromHome = 0
- currentDigDepth = 0
- torchSlot = 16
- function turn(turnFor)
- if turnFor > 0 then
- lastTurn = 1
- for i=1,turnFor do
- turtle.turnRight()
- end
- elseif turnFor < 0 then
- lastTurn = -1
- turnFor = -1 * turnFor
- for i=1,turnFor do
- turtle.turnLeft()
- end
- end
- end
- function dig(digDistance)
- for currentDigDepth=1,digDistance do
- while turtle.detectDown() or turtle.detect() or turtle.detectUp() do
- turtle.digUp()
- turtle.digDown()
- turtle.dig()
- sleep(.2)
- end
- move(1)
- end
- end
- function fuelCheck()
- -- if(turtle.getFuelLevel() <= distanceFromHome) then
- -- if(turtle.getItemCount(16) > 0) then
- -- turtle.select(16)
- -- else
- -- turtle.select(16)
- -- print("Need Fuel!")
- -- getHome()
- -- exit()
- -- else
- -- turtle.refuel(1)
- -- end
- -- end
- end
- function getHome()
- end
- function move(moveDistance, moveDirection)
- if(moveDirection == 0 or moveDirection == nil) then
- for currentMoveDistance=1,moveDistance do
- turtle.forward()
- if(currentMoveDistance % 8 == 0) then
- turtle.select(torchSlot)
- turtle.placeDown()
- end
- fuelCheck()
- end
- elseif(moveDirection == 1) then
- for currentMoveDistance=1,moveDistance do
- turtle.up()
- fuelCheck()
- end
- elseif(moveDirection == -1) then
- for currentMoveDistance=1,moveDistance do
- turtle.down()
- fuelCheck()
- end
- end
- moveDirection = nil
- end
- term.clear()
- term.setCursorPos(1,1)
- write("How much space between rows? ")
- rowSpace = tonumber(io.read()) + 1
- write("How many rows? ")
- rowCount = tonumber(io.read())
- write("How deep should the branches be? ")
- branchDepth = tonumber(io.read())
- for currentRow=1,rowCount do
- dig(rowSpace)
- turn(-1)
- dig(branchDepth + 2)
- turn(2)
- move(branchDepth + 2)
- dig(branchDepth + 4)
- turn(2)
- move(branchDepth + 4)
- if(currentRow ~= rowCount) then
- turn(1)
- else
- turn(-1)
- end
- end
- move(rowCount * rowSpace)
- turn(2)
- print("Finished.")
Add Comment
Please, Sign In to add comment