Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local slotCount = 16
- local width = 25
- local length = 25
- local height = 3
- if (arg[1] ~= nil) then
- width = arg[1]
- length = arg[1]
- end
- local trash = {
- "minecraft:cobblestone", "minecraft:stone", "minecraft:andesite",
- "minecraft:diorite", "minecraft:clay_ball", "minecraft:sand",
- "minecraft:sandstone", "minecraft:limestone", "minecraft:dirt",
- "quark:limestone", "minecraft:flint", "rustic:slate", "chisel:limestone2",
- "chisel:limestone", "minecraft:gravel", "minecraft:redstone",
- "minecraft:torch"
- }
- function checkFuel()
- print('Checking fuel...')
- local refueled = false
- if (turtle.getFuelLevel() < 3000) then
- for slot = 1, slotCount, 1 do
- local item = turtle.getItemDetail(slot)
- if (item ~= nil) then
- if (item.name == "minecraft:coal" or item.name ==
- "minecraft:coal_block") then
- print('Attemping to refuel with %d', item.name)
- turtle.select(slot)
- local result = turtle.refuel()
- refueled = true
- print('Turtle refueled...')
- break
- end
- end
- end
- if (refueled == false) then
- print('Did not find coal in inventory.. going to power down soon D:')
- end
- return false
- end
- end
- function stackItems()
- local inventory = {}
- for slot = 1, slotCount, 1 do
- local item = turtle.getItemDetail(slot)
- for invSlot = 1, slotCount, 1 do
- local checking = turtle.getItemDetail(invSlot)
- if (checking ~= nil) then print(checking.name) end
- end
- end
- end
- function flip()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function emptyToChest()
- for slot = 1, slotCount, 1 do
- local item = turtle.getItemDetail(slot)
- if (item ~= nil) then
- if (item.name == "minecraft:oak_chest") then
- turtle.select(slot)
- turtle.placeUp()
- print('chest placed')
- end
- end
- end
- for itemSlot = 1, slotCount, 1 do
- local item = turtle.getItemDetail(itemSlot)
- if (item ~= nil) then
- if (item.name ~= "minecraft:coal" or item.name ==
- "minecraft:coal_block" or item.name == "minecraft:oak_chest") then
- turtle.select(itemSlot)
- turtle.dropUp()
- end
- end
- end
- end
- function checkIfFullInventory()
- local emptySlot = true
- for slot = 1, slotCount, 1 do
- local item = turtle.getItemDetail(slot)
- if (item == nil) then emptySlot = false end
- end
- if (emptySlot == false) then return true end
- return false
- end
- function manageInventory()
- purgeTrash()
- if (checkIfFullInventory() == true) then emptyToChest() end
- end
- function digColumn()
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- turtle.digDown()
- end
- function purgeTrash()
- for slot = 1, slotCount, 1 do
- local item = turtle.getItemDetail(slot)
- if (item ~= nil) then
- for key, value in pairs(trash) do
- if (value == item.name) then
- print("found trash:", item.name)
- print('trash in slot:', slot)
- turtle.select(slot)
- turtle.drop()
- break
- end
- end
- end
- end
- end
- function turnAround(dir)
- print("turning around...")
- if dir == "right" then turtle.turnRight() end
- if dir == "left" then turtle.turnLeft() end
- digColumn()
- if dir == "right" then turtle.turnRight() end
- if dir == "left" then turtle.turnLeft() end
- end
- function checkIfGravel()
- local success, item = turtle.inspect()
- if (success) then
- print(item.name)
- if (item.name == "minecraft:gravel") then return true end
- end
- return false
- end
- function digBlock()
- while turtle.detect() == false do turtle.forward() end
- for row = 1, width, 1 do
- for col = 1, length, 1 do
- checkFuel()
- digColumn()
- if (checkIfGravel() == true) then
- print("found gravel, extending col")
- length = length + 1
- end
- print("col:", col)
- print("length:", length)
- if (col == length) then
- print('i should probably turn around')
- end
- end
- purgeTrash()
- if row % 2 == 1 then turnAround("right") end
- if row % 2 == 0 then turnAround("left") end
- end
- end
- digBlock()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement