Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fuelItUp()
- --Finds out if the turtle needs to refuel and if it has fuel to run
- needsFuel = turtle.getFuelLevel()
- minimumFuelLevel = 10
- hasFuel = turtle.getItemCount(16)
- useFuel = turtle.refuel()
- if needsFuel == "unlimited" then
- else
- if tonumber(needsFuel) < tonumber(minimumFuelLevel) then
- if hasFuel > 0 then
- turtle.select(16)
- turtle.refuel(1)
- turtle.select(1)
- else
- print("Please insert fuel into slot 16")
- repeat os.sleep(1)
- until tonumber(turtle.getItemCount(16)) > 0
- fuelItUp()
- end
- end
- end
- end
- function questions()
- length = 11
- rows = 8
- declarations()
- end
- function declarations()
- currentPos = 0
- currentRow = 1
- startBlock = 1
- startRow = 1
- det = turtle.detect()
- detDown = turtle.detectDown()
- prime()
- end
- function prime()
- fuelItUp()
- turtle.up()
- turtle.up()
- farmDown()
- end
- function farmDown()
- while tonumber(currentPos) ~= tonumber(length) do
- fuelItUp()
- if det == true then
- turtle.dig()
- turtle.forward()
- currentPos = currentPos + 1
- if detDown == true then
- turtle.digDown()
- end
- else
- if detDown == true then
- turtle.digDown()
- end
- end
- end
- if tonumber(currentRow) ~= tonumber(rows) then
- if tonumber(currentRow) % 2 == 0 then
- rightTurn()
- else
- leftTurn()
- end
- else
- ending()
- end
- end
- function leftTurn()
- turtle.turnLeft()
- turtle.forward()
- if det == true then
- turtle.dig()
- turtle.forward()
- end
- turtle.turnLeft()
- if detDown == true then
- turtle.digDown()
- end
- currentRow = currentRow + 1
- farmBack()
- end
- function rightTurn()
- turtle.turnRight()
- turtle.forward()
- if det == true then
- turtle.dig()
- turtle.forward()
- end
- turtle.turnRight()
- if detDown == true then
- turtle.digDown()
- end
- currentRow = currentRow + 1
- farmDown()
- end
- function farmBack()
- while tonumber(currentPos) ~= tonumber(startBlock) do
- fuelItUp()
- if det == true then
- turtle.dig()
- turtle.forward()
- currentPos = currentPos - 1
- if detDown == true then
- turtle.digDown()
- end
- else
- if detDown == true then
- turtle.digDown()
- end
- end
- end
- if tonumber(currentRow) ~= tonumber(rows) then
- if tonumber(currentRow) % 2 == 0 then
- rightTurn()
- else
- leftTurn()
- end
- else
- ending()
- end
- end
- function ending()
- if tonumber(currentRow) % 2 == 0 then
- turtle.forward()
- turtle.turnLeft()
- turtle.down()
- turtle.down()
- else
- turtle.turnLeft()
- turtle.turnLeft()
- while tonumber(currentPos) ~= tonumber(startBlock - 1) do
- turtle.forward()
- currentPos = currentPos - 1
- end
- turtle.turnLeft()
- turtle.down()
- turtle.down()
- end
- while tonumber(currentRow) ~= tonumber(startRow) do
- fuelItUp()
- turtle.forward()
- turtle.forward()
- currentRow = currentRow - 1
- end
- dropoff()
- end
- function dropoff()
- s = 1
- total = 0
- while s < 16 do
- items = turtle.getItemCount(s)
- total = items + total
- if items > 0 then
- turtle.select(s)
- turtle.drop()
- end
- s = s + 1
- end
- turtle.turnLeft()
- print("Total Items Deposited:")
- print(total)
- end
- questions()
Advertisement
Add Comment
Please, Sign In to add comment