Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------
- -- Made by nDoorn --
- --------------------
- --- Version 1.0 ---
- ------------------------------
- -- How to use this program? --
- ------------------------------
- -- Place an Fuel chest in slot 16
- -- Place an Item chest in slot 15
- -- Set the settings
- -- Start the program!
- ------------------
- ---- SETTINGS ----
- ------------------
- local radius = 5
- local depth = 5
- local quarters = 1
- local minFuelLevel = 600
- --------------------------------------------
- ---------------- FUNCTIONS -----------------
- --------------------------------------------
- function round(num) return math.floor(num + 0.5) end
- function digCircle(grid)
- local X = 0
- local Y = 0
- local DigDepth = depth - 2
- local GridValue = 0
- checkFuel()
- while true do
- for i=1, quarters, 1 do
- while true do
- if (grid[X][Y + 1] == 1) then
- tForwardDig(1)
- Y = Y + 1
- else
- tBack(Y)
- Y = 0
- depositItems()
- checkFuel()
- if (grid[X+1][Y] == 1) then
- turtle.turnRight()
- tForwardDig(1)
- X = X + 1
- turtle.turnLeft()
- else
- turtle.turnRight()
- tBack(X)
- X = 0
- break
- end
- end
- end
- end
- for i=1, quarters, 1 do
- turtle.turnLeft()
- end
- if (DigDepth == 0) then
- break
- end
- if (DigDepth == 1) then
- turtle.digDown()
- turtle.down()
- turtle.digDown()
- DigDepth = DigDepth - 1
- end
- if (DigDepth >= 2) then
- turtle.digDown()
- turtle.down()
- turtle.digDown()
- turtle.down()
- turtle.digDown()
- DigDepth = DigDepth - 2
- end
- depositItems()
- end
- print("-----------------------------")
- print("-- Yay, i am done. Phew :) --")
- print("-----------------------------")
- end
- function tForwardDig(steps)
- for k=1, steps, 1 do
- turtle.dig()
- turtle.forward()
- turtle.digDown()
- end
- end
- function tLeft(steps)
- for k=1, steps, 1 do
- turtle.turnLeft()
- end
- end
- function tRight(steps)
- for k=1, steps, 1 do
- turtle.turnRight()
- end
- end
- function tBack(steps)
- for k=1, steps, 1 do
- turtle.back()
- end
- end
- function checkFuel()
- local fuel = turtle.getFuelLevel()
- local refuelItems = 0
- if fuel < minFuelLevel then
- turtle.select(16) -- Select the Fuel chest
- turtle.placeUp() -- Place the fuel chest
- turtle.suckUp() -- Get some fuel from the chest
- refuelItems = turtle.getItemCount(16) -- Get the number of fuel items
- turtle.refuel(refuelItems) -- Refuel the turtle
- turtle.digUp() -- Pickup the chest again
- end
- end
- function depositItems()
- turtle.select(15) -- Select the item chest slot
- turtle.placeUp() -- Place the item chest
- for i=1, 14, 1 do -- Go through all the slots of the turtle
- turtle.select(i) -- Select slot 1 - 14
- if (turtle.getItemCount ~= 0) then -- check if there is an item there
- turtle.dropUp() -- If there is, put it in the chest
- end
- end
- turtle.select(15) -- Select slot 15
- turtle.digUp() -- Pick up the chest
- end
- --------------------------------------------
- ------------------- CODE -------------------
- --------------------------------------------
- term.clear()
- -- Create an array
- local grid = {}
- for x=0, radius, 1 do
- grid[x] = {}
- for y=0, radius, 1 do
- grid[x][y] = 0
- end
- end
- local original = {}
- term.clear()
- term.setCursorPos(1,1)
- print("Circle radius is : ", radius)
- print("Circle depth is : ", depth)
- print("Turtle fuel level: ", turtle.getFuelLevel())
- print("")
- print("Calculating the grid")
- -- Calculate the step values
- for i=0, radius - 1, 1 do --for i=0, radius - 1, 1 do
- local buffer = 0
- buffer = math.sqrt(math.pow(radius, 2) - math.pow(i, 2))
- buffer = round(buffer) - 1
- for j=i, buffer, 1 do
- grid[i][j] = 1
- end
- for j=i, buffer, 1 do
- grid[j][i] = 1
- end
- end
- print ("Starting with digging")
- print ("")
- digCircle(grid)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement