Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local SLOT_COUNT = 16
- local minecount = 0
- local args = { ... }
- if #args == 0 then
- print("Usage:stripmine <tunnel length> <number of tunnels>")
- error()
- end
- local length = args[1]
- local tunnels = 1
- if #args == 2 then
- tunnels = args[2]
- end
- function turnAround()
- turtle.turnRight()
- turtle.turnRight()
- end
- function getItemIndex(itemName)
- for slot = 1, SLOT_COUNT, 1 do
- local item = turtle.getItemDetail(slot)
- if(item ~= nil) then
- if(item["name"] == itemName) then
- return slot
- end
- end
- end
- end
- function checkFuel()
- while(turtle.getFuelLevel() < 500) do
- print("Refuelling...")
- fuelIndex = getItemIndex("minecraft:coal")
- if(fuelIndex ~= nil) then
- turtle.select(fuelIndex)
- turtle.refuel()
- print("Fuel level: "..turtle.getFuelLevel())
- end
- end
- end
- function storeInventory()
- if getItemIndex("enderstorage:ender_storage") then
- chestIndex = getItemIndex("enderstorage:ender_storage")
- turtle.select(chestIndex)
- turtle.placeUp()
- for slot = 1, SLOT_COUNT do
- local item = turtle.getItemDetail(slot)
- turtle.select(slot)
- if(item ~= nil) then
- local itemname = item["name"]
- if(itemname ~= "minecraft:torch" and itemname ~= "minecraft:coal") then
- turtle.dropUp()
- end
- end
- end
- turtle.digUp()
- end
- end
- function digAndMove()
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- turtle.digDown()
- turtle.digUp()
- minecount = minecount + 1
- if(minecount == 30) then
- print("Storing inventory")
- storeInventory()
- minecount = 0
- end
- end
- function placeTorch()
- if getItemIndex("minecraft:torch") then
- local torchIndex = getItemIndex("minecraft:torch")
- turnAround()
- turtle.select(torchIndex)
- turtle.down()
- turtle.place()
- turtle.up()
- turnAround()
- end
- end
- function nextTunnel()
- turtle.turnLeft()
- for i = 1, 4 do
- digAndMove()
- turtle.digUp()
- end
- turtle.turnRight()
- end
- function digTunnel()
- local tunnelsteps = 1
- for i = 1, length do
- digAndMove()
- if tunnelsteps % 7 == 0 then
- placeTorch()
- tunnelsteps = 0
- end
- tunnelsteps = tunnelsteps + 1
- end
- turtle.turnRight()
- digAndMove()
- turtle.turnRight()
- for i = 1, length do
- digAndMove()
- end
- --Return to starting position
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- end
- for i = 1, tunnels do
- digTunnel()
- nextTunnel()
- checkFuel()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement