Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Version 5 (WIP)
- local nLimit = 1
- local badItems = {}
- badItems[1] = "minecraft:cobblestone"
- badItems[2] = "minecraft:andesite"
- badItems[3] = "minecraft:dirt"
- badItems[4] = "minecraft:diorite"
- badItems[5] = "minecraft:granite"
- badItems[6] = "minecraft:gravel"
- badItems[7] = "extractinator:silt"
- badItems[8] = "minecraft:cobbled_deepslate"
- badItems[9] = "minecraft:sand"
- badItems[10] = "minecraft:sandstone"
- badItems[11] = "minecraft:tuff"
- badItems[12] = "minecraft:calcite"
- badItems[13] = "minecraft:dripstone_block"
- badItems[14] = "minecraft:pointed_dripstone"
- badItems[15] = "minecraft:mossy_cobblestone"
- badItems[16] = "minecraft:flint"
- function localRefuel()
- if turtle.getFuelLevel() ~= "unlimited" then
- for n=1,16 do
- local nCount = turtle.getItemCount(n)
- if nLimit > 0 and nCount > 0 and turtle.getFuelLevel() < turtle.getFuelLimit() then
- local nBurn = math.min( nLimit, nCount )
- turtle.select( n )
- if turtle.refuel( nBurn ) then
- local nNewCount = turtle.getItemCount(n)
- nLimit = nLimit - (nCount - nNewCount)
- end
- end
- end
- end
- turtle.select(1)
- end
- function fakeInventory()
- fakeSlots = {}
- for i = 1,16 do
- if turtle.getItemDetail(i) ~= nil then
- fakeSlots[i] = turtle.getItemDetail(i).name
- end
- end
- return fakeSlots
- end
- function sortInventory()
- for i = 1,16 do
- fakeSlots = fakeInventory()
- if turtle.getItemDetail(i) ~= nil then
- containsItem = 0
- for j = 1,16 do
- if fakeSlots[j] == turtle.getItemDetail(i).name then
- if containsItem == 0 then
- if turtle.getItemCount(j) < 64 then
- containsItem = j
- end
- end
- end
- end
- if containsItem ~= 0 then
- if containsItem ~= i then
- if turtle.getItemCount(i) < 64 then
- turtle.select(i)
- turtle.transferTo(containsItem)
- end
- end
- end
- end
- end
- for i = -16,-1 do
- emptySlot = 0
- for j = 1,16 do
- if turtle.getItemDetail(j) == nil then
- emptySlot = j
- break
- end
- end
- if emptySlot ~= 0 then
- if emptySlot < i*-1 then
- if turtle.getItemDetail(i*-1) ~= nil then
- turtle.select(i*-1)
- turtle.transferTo(emptySlot)
- end
- end
- end
- end
- turtle.select(1)
- end
- function checkInventory()
- for i = 1,16 do
- for j = 1,16 do
- if turtle.getItemDetail(i) ~= nil then
- if turtle.getItemDetail(i).name == badItems[j] then
- turtle.select(i)
- turtle.drop(64)
- end
- end
- end
- end
- sortInventory()
- end
- function clearScreen()
- term.clear()
- term.setCursorPos(1,1)
- end
- function setup()
- posX = 0
- posY = 0
- posZ = 0
- rotation = 0
- layerType = 0
- clearScreen()
- io.write("Quarry or bore? ")
- mineType = io.read()
- clearScreen()
- io.write("Rows: ")
- rows = io.read()
- io.write("Columns: ")
- columns = io.read()
- clearScreen()
- if mineType == "quarry" then
- io.write("Current 'y' level: ")
- iniY = io.read()
- iniY = tonumber (iniY)
- clearScreen()
- end
- start()
- end
- function info()
- clearScreen()
- print("Creating a " .. rows .. "x" .. columns .. " " .. mineType)
- print("Total distance: " .. posX + posY + posZ)
- print("X: " .. posX)
- print("Y: " .. posY)
- print("Z: " .. posZ)
- print("Rotation: " .. rotation)
- print("Layer Type: " .. layerType)
- print("Fuel level: " .. turtle.getFuelLevel())
- end
- function orientate()
- if rotation == 0 then
- turtle.turnLeft()
- rotation = 3
- info()
- elseif rotation == 1 then
- turtle.turnLeft()
- rotation = 0
- info()
- turtle.turnLeft()
- rotation = 3
- info()
- elseif rotation == 2 then
- turtle.turnRight()
- rotation = 3
- info()
- end
- end
- function recover()
- orientate()
- stepY = posY
- stepX = posX
- stepZ = posZ
- for posY = stepY - 1, 0, -1 do
- turtle.up()
- info()
- end
- for posX = stepX - 1, 0, -1 do
- turtle.forward()
- info()
- end
- turtle.turnLeft()
- for posZ = stepZ - 1, 0, -1 do
- turtle.forward()
- info()
- end
- end
- function digStraight()
- turtle.digDown()
- turtle.dig()
- turtle.dig()
- turtle.forward()
- if rotation == 0 then
- posZ = posZ + 1
- elseif rotation == 1 then
- posX = posX + 1
- elseif rotation == 2 then
- posZ = posZ - 1
- elseif rotation == 3 then
- posX = posX - 1
- end
- turtle.digUp()
- sortInventory()
- info()
- end
- function nextRow()
- if layerType == 0 then
- if rotation == 0 then
- turtle.turnRight()
- rotation = 1
- info()
- digStraight()
- turtle.turnRight()
- rotation = 2
- info()
- elseif rotation == 2 then
- turtle.turnLeft()
- rotation = 1
- info()
- digStraight()
- turtle.turnLeft()
- rotation = 0
- info()
- end
- elseif layerType == 1 then
- if rotation == 0 then
- turtle.turnLeft()
- rotation = 3
- info()
- digStraight()
- turtle.turnLeft()
- rotation = 2
- info()
- elseif rotation == 2 then
- turtle.turnRight()
- rotation = 3
- info()
- digStraight()
- turtle.turnRight()
- rotation = 0
- info()
- end
- end
- end
- function nextLayer()
- turtle.turnRight()
- if rotation == 0 then
- rotation = 1
- info()
- elseif rotation == 2 then
- rotation = 3
- info()
- end
- turtle.turnRight()
- if rotation == 1 then
- rotation = 2
- info()
- elseif rotation == 3 then
- rotation = 0
- info()
- end
- turtle.down()
- posY = posY + 1
- info()
- turtle.digDown()
- turtle.down()
- posY = posY + 1
- info()
- turtle.digDown()
- turtle.down()
- posY = posY + 1
- info()
- if layerType == 0 then
- layerType = 1
- elseif layerType == 1 then
- layerType = 0
- end
- end
- function layerMove()
- for c = columns, 1, -1 do
- for r = rows, 2, -1 do
- if turtle.getFuelLevel() < 1 then
- localRefuel()
- end
- digStraight()
- end
- if c > 1 then
- checkInventory()
- nextRow()
- else
- turtle.digDown()
- end
- end
- end
- function quarry()
- turtle.digDown()
- turtle.down()
- posY = posY + 1
- info()
- turtle.digDown()
- turtle.down()
- posY = posY + 1
- info()
- while posY < iniY - 2 do
- layerMove()
- nextLayer()
- end
- recover()
- end
- function bore()
- turtle.up()
- posY = posY + 1
- info()
- turtle.dig()
- turtle.forward()
- posZ = posZ + 1
- info()
- turtle.digUp()
- layerMove()
- recover()
- end
- function start()
- if mineType == "quarry" then
- quarry()
- elseif mineType == "bore" then
- bore()
- else
- setup()
- end
- end
- setup()
Advertisement
Add Comment
Please, Sign In to add comment