Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function refuel()
- --check inventory for fuel
- local maxFuel = 200
- --cycles through each slot refuelling
- --using everything in that slot
- --until full
- for i=3, 16 do
- if turtle.getFuelLevel() < maxFuel then
- turtle.select(i)
- turtle.refuel()
- end
- end
- --if not enough, use enderchest
- if turtle.getFuelLevel() < maxFuel then
- --select enderchest, place above
- while turtle.getItemCount(2) ~= 0 do
- turtle.select(2)
- turtle.placeUp()
- sleep(1)
- end
- --keep grabbing fuel until full
- while turtle.getFuelLevel() < maxFuel do
- if turtle.suckUp() == false then
- break --if no fuel available
- --then stop refueling
- end
- turtle.refuel()
- end
- --replace enderchest
- turtle.digUp()
- end
- --reselect slot 1
- turtle.select(1)
- end
- function unload()
- --places enderchest above
- while turtle.getItemCount(1) ~= 0 do
- turtle.select(1)
- turtle.placeUp()
- sleep(1)
- end
- --dumps all items in chest
- for i=3, 16 do
- turtle.select(i)
- turtle.dropUp()
- end
- --reselects slot 1
- turtle.select(1)
- turtle.digUp() --gets enderchest back
- end
- function goFwd(dist)
- local minFuel = 10
- for i=1, dist do
- --Refuel if needed
- if turtle.getFuelLevel() < minFuel then
- refuel()
- end
- --move + dig anything infront
- while not turtle.forward() do
- if turtle.getItemCount(16) > 0 then
- unload()
- end
- turtle.dig()
- end
- end
- end
- function digSquare(N)
- --digs an N*N square
- --dig square except last row
- for i=1, (N-1) do
- --on odd rows
- if i % 2 == 1 then
- goFwd((N-1))
- turtle.turnRight()
- goFwd(1)
- turtle.turnRight()
- else --on even rows
- goFwd((N-1))
- turtle.turnLeft()
- goFwd(1)
- turtle.turnLeft()
- end
- end
- --finish last row without the dig turn
- --turn so in bottom left of square
- goFwd((N-1))
- turtle.turnRight()
- if (N%2) == 1 then
- turtle.turnRight()
- end
- end
- function goDown()
- --checks for inv space
- if turtle.getItemCount(16) > 0 then
- unload()
- end
- --then goes down
- turtle.digDown()
- turtle.down()
- end
- function goUp(N)
- for i=1, N do
- --checks fuel
- if turtle.getFuelLevel < minFuel then
- refuel()
- end
- --checks for space
- if turtle.getItemCount(16) > 0 then
- unload()
- end
- while not turtle.up() do
- turtle.digUp()
- end
- end
- end
- function quarry(depth, size)
- for i=1, depth do
- goDown()
- digSquare(size)
- end
- end
- --need up function
- --ACTUAL PROGRAM--
- term.clear()
- term.setCursorPos(1, 1)
- print("Place item chest in slot 1")
- print("and fuel chest in slot 2")
- print("Then enter how far you would like to")
- print("dig down")
- local depth = read()
- local depthNum = tonumber(depth)
- print("Enter how big the square")
- print("to dig should be")
- local size = read()
- local sizeNum = tonumber(size)
- quarry(depthNum, sizeNum)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement