Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Using the program
- local height = 0
- local width = 0
- local depth = 0
- if #arg == 3 then
- height = tonumber(arg[1])
- width = tonumber(arg[2])
- depth = tonumber(arg[3])
- if width % 2 == 0 or height % 2 == 0 then
- print("The Width and Height need to be odd numbers")
- return
- elseif width == 1 or height == 1 then
- print("The Width and Height need to be more that one")
- return
- end
- else
- print("There needs to be three correct arguments (e.g. mine 5 5 10)")
- return
- end
- -- useful Vars
- local INVENTORY_SIZE = 16
- local mineHeight = math.floor(height / 2)
- local mineWidth = math.floor(width / 2)
- -- List of fuels
- local FUELS = {
- "minecraft:coal_block",
- "minecraft:coal",
- "minecraft:lava_bucket"
- }
- -- Whitelist for inventory
- local WHITELISTED_ITEMS = {
- "minecraft:coal",
- "minecraft:coal_block",
- "minecraft:redstone",
- "minecraft:dye",
- "minecraft:emerald",
- "minecraft:gold_ore",
- "minecraft:iron_ore",
- "minecraft:diamond",
- "minecraft:lava_bucket",
- "thermalfoundation:ore",
- "bigreactors:oreyellorite",
- "tconstruct:ore",
- "ic2:nuclear",
- "draconicevolution:draconium_dust"
- }
- -- Checks Inventory
- function InventoryCheck()
- -- Checks for shit items then drops them if bad
- for i = 1, INVENTORY_SIZE do
- local currentItem = turtle.getItemDetail(i)
- if currentItem ~= nil then
- local isAcceptedItem = false
- for x = 1, #WHITELISTED_ITEMS do
- if currentItem.name == WHITELISTED_ITEMS[x] then
- isAcceptedItem = true
- end
- end
- if not isAcceptedItem then
- turtle.select(i)
- turtle.dropUp()
- end
- end
- end
- -- keeps stuff in stacks
- for j = 1, INVENTORY_SIZE do
- local selectedSlot = turtle.getItemDetail(j)
- if selectedSlot ~= nil then
- turtle.select(j)
- for k = j, INVENTORY_SIZE do
- if turtle.compareTo(k) then
- turtle.select(k)
- turtle.transferTo(j)
- turtle.select(j)
- end
- end
- end
- end
- end
- -- Refuel using the found fuel
- function refuel(slot_number)
- print("[TURTLE] Refueling... ")
- turtle.select(slot_number)
- turtle.refuel()
- print("[TURTLE] Nom. Nom. Nom.")
- end
- -- Check the current fuel level
- function checkFuelLevel()
- local requiredFuelLevel = math.ceil((height * width * depth) + (mineHeight + mineWidth))
- local currentFuelLevel = turtle.getFuelLevel()
- print("[TURTLE] Current fuel level is: "..currentFuelLevel.." - Required: "..requiredFuelLevel)
- if currentFuelLevel < requiredFuelLevel then
- print("[TURTLE] Attempting to locate fuel.")
- for i = 1, INVENTORY_SIZE do
- local currentItem = turtle.getItemDetail(i)
- if currentItem ~= nil then
- for x = 1, #FUELS do
- if currentItem.name == FUELS[x] then
- print("[TURTLE] Acceptable fuel found: " ..FUELS[x])
- if currentFuelLevel < requiredFuelLevel then
- refuel(i)
- else
- return true
- end
- end
- end
- end
- end
- print("[TURTLE] No acceptable fuel or not enough found, terminating program...")
- return false
- else
- return true
- end
- end
- -- Combat gravel/sand
- function moveUpAndDig()
- while turtle.up() == false do
- turtle.digUp()
- end
- end
- function moveForwardAndDig()
- while turtle.forward() == false do
- turtle.dig()
- InventoryCheck()
- end
- end
- function moveDownAndDig()
- while turtle.down() == false do
- turtle.digDown()
- end
- end
- -- Move to start position
- function moveToStartPosition()
- -- Move to horizontal start position
- turtle.turnLeft()
- for i = 1, mineWidth do
- moveForwardAndDig()
- end
- turtle.turnRight()
- -- Move to vertical start postion
- for i = 1, mineHeight do
- moveUpAndDig()
- end
- end
- -- Mining Sequence
- function mineSequence()
- moveToStartPosition()
- for x = 1, depth do
- moveForwardAndDig()
- for i = 1, height do
- if x % 2 == 0 then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- for y = 1, width - 1 do
- moveForwardAndDig()
- end
- if i ~= height then
- if x % 2 == 0 then
- turtle.turnLeft()
- moveUpAndDig()
- else
- turtle.turnRight()
- moveDownAndDig()
- end
- end
- end
- if x % 2 == 0 then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- InventoryCheck()
- end
- end
- if checkFuelLevel() then
- mineSequence()
- end
Add Comment
Please, Sign In to add comment