Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Variables
- d = 0 -- depth along the y axis
- w = 1 -- width along the z axis
- l = 0 -- length along the x axis
- f = 0 -- face direction of turtle
- s = 0 -- start variable to break chain of asking for depth/width/length values
- local BlockTable = {
- ["minecraft:grass"] = false,
- ["minecraft:dirt"] = false,
- ["minecraft:stone"] = false,
- ["minecraft:sand"] = false,
- ["minecraft:gravel"] = false,
- ["minecraft:flint"] = false,
- ["minecraft:cobblestone"] = false,
- ["minecraft:iron_ore"] = true,
- ["minecraft:copper_ore"] = true,
- ["minecraft:coal_ore"] = true,
- ["minecraft:gold_ore"] = true,
- ["minecraft:lapis_ore"] = true,
- ["minecraft:obsidian"] = true,
- ["minecraft:diamond_ore"] = true,
- ["minecraft:redstone_ore"] = true,
- ["chisel:granite"] = false,
- ["chisel:limestone"] = false,
- ["chisel:andesite"] = false,
- ["chisel:diorite"] = false,
- ["ThermalFoundation:Ore"] = true,
- ["BigReactors:YelloriteOre"] = true,
- ["appliedenergistics2:tile.OreQuartz"] = true,
- ["appliedenergistics2:tile.OreQuartzCharged"] = true,
- }
- -- Movement Functions
- function TurtleUp()
- if turtle.up() then
- d = d - 1
- end
- end
- function TurtleDown()
- if turtle.down() then
- d = d + 1
- end
- end
- function TurtleForward()
- if f == 2 then
- if turtle.forward() then
- l = l + 1
- end
- end
- if f == 0 then
- if turtle.forward() then
- l = l - 1
- end
- end
- if f == 1 then
- if turtle.forward() then
- w = w - 1
- end
- end
- if f == 3 then
- if turtle.forward() then
- w = w + 1
- end
- end
- end
- function TurtleLeft()
- if turtle.turnLeft() then
- f = f + 1
- f = f % 4
- end
- end
- function next()
- local currX = l
- local currZ = w
- if l < inpLength then
- CheckAlign(2)
- while l > currX + 2 do
- TurtleForward()
- end
- end
- if l > inpLength then
- CheckAlign(0)
- while l > inpLength do
- TurtleForward()
- end
- end
- if l == inpLength then
- CheckAlign(3)
- while w < currZ + 2 do
- TurtleForward()
- end
- CheckAlign(0)
- while l > 0 do
- TurtleForward()
- end
- end
- end
- function Width()
- io.write("Enter a width value:")
- inpWidth = io.read()
- print(inpWidth, " Thank You")
- inpWidth = tonumber(inpWidth)
- end
- function Length()
- io.write("Enter a Length Value: ")
- inpLength = io.read()
- print(inpLength, " Thank You")
- inpLength = tonumber(inpLength)
- end
- function ReturnAndEmpty()
- local currLength = l
- local currWidth = w
- while d > 0 do
- TurtleUp()
- end
- CheckAlign(0)
- while l > 0 do
- if not(TurtleForward()) then
- turtle.dig()
- end
- end
- CheckAlign(2)
- while w > 1 do
- if not(TurtleForward()) then
- turtle.dig()
- end
- end
- CheckAlign(0)
- empty()
- CheckAlign(3)
- if currLength >= inpLength and currWidth >= inpWidth then
- os.shutdown()
- end
- while w > currWidth do
- if not(TurtleForward()) then
- turtle.dig()
- end
- end
- if w == currWidth and l > currLength then
- while l > currLength do
- if not(TurtleForward()) then
- turtle.dig()
- end
- end
- end
- end
- -- Checking Functions
- function Scan()
- while f ~= 3 do
- turtle.inspect()
- MineValue = BlockTable[blockdata.name]
- if MineValue == true then
- turtle.dig()
- end
- TurnLeft()
- end
- CheckAlign(0)
- end
- function CheckFuel()
- if turtle.getFuelLevel() < inpLength then
- turtle.select(1)
- turtle.refuel(1)
- end
- end
- function Count()
- if turtle.getItemCount(16) > 0 then
- ReturnAndEmpty()
- end
- end
- function CheckAlign(dir)
- CheckFuel()
- while f ~= dir do
- TurtleLeft()
- end
- end
- function empty()
- for i = 2,16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(2)
- end
- function dig()
- while s = 0 do
- Length()
- Width()
- s = s + 1
- end
- while turtle.inspectDown() ~= ["minecraft:bedrock"] do
- turtle.digDown()
- Scan()
- TurtleDown()
- end
- if turtle.inspectDown() == ["minecraft:bedrock"] then
- next()
- end
- if w >= inpWidth and l >= inpLength then
- ReturnAndEmpty()
- end
- end
- while true do
- dig()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement