Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = 0
- y = 64
- z = 0
- homeX = 0
- homeY = 64
- homeZ = 0
- digDepth = 5
- facing = "north"
- coalSlots = {2,3,4}
- ironSlots = {5,6,7}
- goldSlots = {8,9}
- redstoneSlots = {10,11,12}
- lapisSlots = {13,14,15}
- diamondSlots = {16}
- function refuelWithCoal()
- selectFromList(coalList)
- turtle.refuel()
- end
- function selectFromList(list)
- for i, v in ipairs(list) do
- turtle.select(v)
- if turtle.getItemCount() > 0 then
- break
- end
- end
- end
- function spaceLeft(slotList)
- space = 0
- for i, v in ipairs(slotList) do
- space = space + turtle.getItemSpace(v)
- end
- return space
- end
- function setOres(c,i,g,r,l,d)
- file = fs.open("ores.txt", "w")
- file.writeLine(c)
- file.writeLine(i)
- file.writeLine(g)
- file.writeLine(r)
- file.writeLine(l)
- file.writeLine(d)
- file.close()
- end
- function setCoords(xx,yy,zz)
- file = fs.open("coords.txt", "w")
- file.writeLine(xx)
- file.writeLine(yy)
- file.writeLine(zz)
- file.close()
- end
- function setHome(hx,hy,hz)
- file = fs.open("home", "w")
- file.writeLine(hx)
- file.writeLine(hy)
- file.writeLine(hz)
- file.close()
- end
- function getOres()
- file = fs.open("ores.txt", "r")
- coal = tonumber(file.readLine())
- iron = tonumber(file.readLine())
- gold = tonumber(file.readLine())
- redstone = tonumber(file.readLine())
- lapis = tonumber(file.readLine())
- diamond = tonumber(file.readLine())
- end
- function getCoords()
- file = fs.open("coords.txt", "r")
- x = tonumber(file.readLine())
- y = tonumber(file.readLine())
- z = tonumber(file.readLine())
- end
- function getHome()
- file = fs.open("home.txt", "r")
- homeX = tonumber(file.readLine())
- homeY = tonumber(file.readLine())
- homeZ = tonumber(file.readLine())
- end
- function getUsedSlots(n)
- return math.ceil(n/64)
- end
- function getTotalUsedSlots(c,i,g,r,l,d)
- t = getUsedSlots(c) + getUsedSlots(i) + getUsedSlots(g) + getUsedSlots(r) + getUsedSlots(l) + getUsedSlots(d)
- return t
- end
- function move(dir)
- getCoords()
- if dir == "forward" then
- turtle.forward()
- if facing == "north" then
- x = x + 1
- end
- if facing == "south" then
- x = x - 1
- end
- if facing == "east" then
- z = z + 1
- end
- if facing == "west" then
- z = z - 1
- end
- end
- if dir == "back" then
- turtle.back()
- if facing == "north" then
- x = x - 1
- end
- if facing == "south" then
- x = x + 1
- end
- if facing == "east" then
- z = z - 1
- end
- if facing == "west" then
- z = z + 1
- end
- end
- if dir == "up" then
- turtle.up()
- y = y + 1
- end
- if dir == "down" then
- turtle.down()
- y = y - 1
- end
- if dir == "right" then
- turtle.turnRight()
- if facing == "north" then
- facing = "east"
- elseif facing == "east" then
- facing = "south"
- elseif facing == "south" then
- facing = "west"
- elseif facing == "west" then
- facing = "north"
- end
- end
- if dir == "left" then
- turtle.turnLeft()
- if facing == "north" then
- facing = "west"
- elseif facing == "west" then
- facing = "south"
- elseif facing == "south" then
- facing = "east"
- elseif facing == "east" then
- facing = "north"
- end
- end
- print("Coords")
- print(x)
- print(y)
- print(z)
- print(facing)
- setCoords(x,y,z)
- end
- function digColumn()
- while turtle.getFuelLevel() < 100 do
- refuelWithCoal()
- end
- while y > digDepth do
- success, data = turtle.inspectDown()
- if data.name == "minecraft:lava" then
- turtle.select(1)
- turtle.placeDown()
- turtle.refuel()
- for i = 0, 3 do
- turtle.place()
- move("left")
- end
- end
- turtle.digDown()
- move("down")
- end
- while y < homeY do
- move("up")
- end
- end
- function digRow(n)
- for a = 1, n do
- move("forward")
- move("forward")
- move("forward")
- digColumn()
- end
- for a = 1, n do
- move("back")
- move("back")
- move("back")
- end
- end
- function changeRowPlus()
- move("right")
- move("forward")
- move("forward")
- move("left")
- move("forward")
- end
- function changeRowMinus()
- move("left")
- move("forward")
- move("forward")
- move("left")
- move("forward")
- move("left")
- move("left")
- end
- function dig(nCols, nRows)
- digRow(nCols)
- for q = 2, nRows do
- changeRowPlus()
- digRow(nCols)
- end
- for q = 2, nRows do
- changeRowMinus()
- end
- end
- function goHome()
- while facing ~= "north" do
- move("left")
- end
- print("FACING NORTH")
- while y ~= homeY do
- move("up")
- end
- print("Y HOMED")
- while x ~= homeX do
- move("back")
- end
- print("X HOMED")
- move("left")
- while z ~= homeZ do
- move("forward")
- end
- print("Z HOMED")
- move("right")
- print("READY TO MINE")
- end
- goHome()
- dig(25,25)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement