Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local numSlots = 16
- local HDG = "north"
- local width, depth, height = 5, 5, 2
- if(#arg == 3) then
- width = tonumber(arg[1])
- depth = tonumber(arg[2])
- height = tonumber(arg[3])
- else
- print("Digging 5x5x2")
- end
- Dropped_Items = {
- "minecraft:stone",
- "minecraft:dirt",
- "minecraft:gravel",
- "minecraft:flint",
- "minecraft:sand",
- "minecraft:cobblestone",
- "minecraft:redstone",
- "minecraft:dye",
- "thaumcraft:nugget",
- "thaumcraft:crystal_essence",
- "thaumcraft:ore_cinnabar",
- "thermalfoundation:material",
- "railcraft:ore_metal",
- "extrautils2:ingredients",
- "projectred-core:resource_item",
- "deepresonance:resonating_ore",
- "forestry:apatite"
- }
- -- Function for dropping unwanted items
- function dropItems()
- for slot = 1, numSlots, 1 do
- local item = turtle.getItemDetail(slot)
- if(item ~= nil) then
- for droppedItemsIndex = 1, #Dropped_Items, 1 do
- if(item["name"] == Dropped_Items[droppedItemsIndex]) then
- turtle.select(item)
- turtle.dropDown()
- end
- end
- end
- end
- end
- --Function to find ender chest in the inventory
- function getEnderSlot()
- for slot = 1, numSlots, 1 do
- local item = turtle.getItemDetail(slot)
- if(item ~= nil) then
- if(item["name"] == "enderstorage:ender_storage") then
- return slot
- end
- end
- end
- return nil
- end
- --Function to drop items after each row
- function manageInventory()
- dropItems()
- enderSlot = getEnderSlot()
- if(enderSlot ~= nil) then
- turtle.select(enderSlot)
- turtle.digUp()
- turtle.placeUp()
- end
- --Ender chest has been placed
- for slot = 1, numSlots, 1 do
- local item = turtle.getItemDetail(slot)
- if(item ~= nil) then
- if(item["name"] ~= "minecraft:coal_block" and item["name"] ~= "minecraft:coal" and item["name"] ~= "enderstorage:ender_storage") then
- turtle.select(slot)
- turtle.dropUp()
- end
- end
- end
- --Wanted items have been stored
- turtle.digUp()
- end
- --Checks fuel level
- function checkFuel()
- turtle.select(1)
- if(turtle.getFuelLevel() < 50) then
- print("Attempting to refuel")
- for slot = 1, numSlots, 1 do
- turtle.select(slot)
- if(turtle.refuel(1)) then
- return true
- end
- end
- return false
- else
- return true
- end
- end
- function detectDig()
- while(turtle.detectUp() or turtle.detectDown() or turtle.detect()) do
- turtle.dig()
- turtle.digUp()
- turtle.digDown()
- end
- end
- function forward()
- detectDig()
- turtle.forward()
- end
- function leftHalfTurn()
- turtle.turnLeft()
- detectAndDig()
- turtle.forward()
- turtle.turnLeft()
- detectAndDig()
- end
- function rightHalfTurn()
- turtle.turnRight()
- detectAndDig()
- turtle.forward()
- turtle.turnRight()
- detectAndDig()
- end
- function flipDirection()
- if(HDG == "north") then
- HDG = "south"
- elseif(HDG == "south") then
- HDG = "north"
- elseif(HDG == "west") then
- HDG = "east"
- elseif(HDG == "east") then
- HDG = "west"
- end
- end
- function turnAround(level)
- if(level % 2 == 1) then
- if(HDG == "north" or HDG == "west") then
- leftHalfTurn()
- elseif(HDG == "south" or HDG == "east") then
- rightHalfTurn()
- end
- else
- if(HDG == "north" or HDG == "west") then
- rightHalfTurn()
- elseif(HDG == "south" or HDG == "east") then
- leftHalfTurn()
- end
- end
- flipDirection()
- end
- function upLevelX3()
- turtle.turnRight()
- turtle.turnRight()
- flipDirection()
- turtle.digUp()
- turtle.up()
- turtle.digUp()
- turtle.up()
- turtle.digUp()
- turtle.up()
- end
- function main()
- for level = 1, height, 1 do
- for X = 1, width, 1 do
- for Y = 1, depth, 1 do
- if(not checkFuel()) then
- print("Turtle is out of fuel.")
- return
- end
- forward()
- print(string.format("X: %d Y: %d", X, Y))
- end
- if(X ~= width) then
- turnAround(level)
- end
- manageInventory()
- end
- upLevelX3()
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement