Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local SLOT_COUNT = 16
- local d = "north"
- local width, depth, height = 10, 10, 2
- if (#arg == 3) then
- width = tonumber(arg[1])
- depth = tonumber(arg[2])
- height = tonumber(arg[3])
- else
- print('None or Malformed Size Given, Defaulting to 10x10x2 up')
- end
- BLACK_LIST = {
- "minecraft:stone",
- "minecraft:dirt",
- "minecraft:cobblestone",
- "minecraft:sand",
- "minecraft:granite",
- "minecraft:andesite",
- "minecraft:diorite",
- "extcaves:sedimentstone",
- "powah:dry_ice",
- "extcaves:lavastone",
- "create:weathered_limestone",
- "astralsorcery:marble_raw",
- "create:scoria",
- "mana-and-artifice:vinteum_ore"
- }
- function getEnderIndex()
- for slot = 1, SLOT_COUNT, 1 do
- local item = turtle.getItemDetail(slot)
- if(item ~= nil) then
- if(item["name"] == "enderstorage:ender_chest") then
- return slot
- end
- end
- end
- return nil
- end
- function manageInventory()
- index = getEnderIndex()
- if(index ~= nil) then
- turtle.select(index)
- turtle.digUp()
- turtle.placeUp()
- end
- -- Chest is now deployed
- local coalSlot = -1
- for slot = 1, SLOT_COUNT, 1 do
- local item = turtle.getItemDetail(slot)
- if(item ~= nil) then
- turtle.select(slot)
- if(item["name"] == "minecraft:coal") then
- if (coalSlot == -1) then
- coalSlot = slot
- else
- turtle.transferTo(coalSlot)
- end
- end
- if (slot ~= coalSlot and slot ~= index) then
- turtle.dropUp()
- end
- end
- end
- -- Items are now stored
- turtle.digUp()
- end
- function checkFuel()
- turtle.select(1)
- if(turtle.getFuelLevel() < 50) then
- print("Attempting Refuel...")
- for slot = 1, SLOT_COUNT, 1 do
- turtle.select(slot)
- if(turtle.refuel(5)) then
- return true
- end
- end
- return false
- else
- return true
- end
- end
- function checkBlock(force, check, dig)
- local name = select(2, check())["name"]
- local shouldDig = true
- if (force == false) then
- for filterIndex = 1, #BLACK_LIST, 1 do
- if(name == BLACK_LIST[filterIndex]) then
- shouldDig = false
- end
- end
- end
- if (shouldDig) then
- dig()
- end
- end
- function detectAndDig()
- checkBlock(true, turtle.inspect, turtle.dig)
- checkBlock(false, turtle.inspectUp, turtle.digUp)
- checkBlock(false, turtle.inspectDown, turtle.digDown)
- end
- function forward()
- detectAndDig()
- turtle.forward()
- end
- function leftTurn()
- turtle.turnLeft()
- detectAndDig()
- turtle.forward()
- turtle.turnLeft()
- detectAndDig()
- end
- function rightTurn()
- turtle.turnRight()
- detectAndDig()
- turtle.forward()
- turtle.turnRight()
- detectAndDig()
- end
- function flipDirection()
- if(d == "north") then
- d = "south"
- elseif(d == "south") then
- d = "north"
- elseif(d == "west") then
- d = "east"
- elseif(d == "east") then
- d = "west"
- end
- end
- function turnAround(tier)
- if(tier % 2 == 1) then
- if(d == "north" or d == "east") then
- rightTurn()
- elseif(d == "south" or d == "west") then
- leftTurn()
- end
- else
- if(d == "north" or d == "east") then
- leftTurn()
- elseif(d == "south" or d == "west") then
- rightTurn()
- end
- end
- flipDirection()
- end
- function riseTier()
- turtle.turnRight()
- turtle.turnRight()
- flipDirection()
- turtle.digUp()
- turtle.up()
- turtle.digUp()
- turtle.up()
- turtle.digUp()
- turtle.up()
- end
- function start()
- turtle.digUp()
- turtle.up()
- for tier = 1, height, 1 do
- for col = 1, width, 1 do
- for row = 1, depth - 1, 1 do
- if(not checkFuel()) then
- print("Turtle is out of fuel, Powering Down...")
- return
- end
- forward()
- print(string.format("Row: %d Col: %d", row, col))
- end
- if(col ~= width) then
- turnAround(tier)
- end
- manageInventory()
- end
- riseTier()
- end
- end
- start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement