Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- only to dig a small strip mining tunnel
- local numTunnels = 5
- local tunLength = 30
- function turnAround()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function turtleForward()
- local numOfWait = 0
- while(turtle.forward() == false)do
- local success, data = turtle.inspect()
- if (success and data.name == "computercraft:CC-TurtleExpanded")then
- os.sleep(0.5)
- if (numOfWait%10 == 0)then
- print("Turtle is waiting in front of me")
- end
- numOfWait = numOfWait + 1
- else
- turtle.dig()
- end
- end
- os.sleep(0.25)
- while(turtle.detectUp())do
- turtle.digUp()
- os.sleep(0.25)
- end
- end
- function placeItemUp(itemName)
- local num = 1
- while (num < 17)do
- local numItems = turtle.getItemCount(num)
- if(numItems > 0)then
- turtle.select(num)
- local data = turtle.getItemDetail()
- if (data)then
- if(data.name == itemName)then
- turtle.placeUp()
- break
- end
- end
- end
- num = num + 1
- end
- end
- function placeItem(itemName)
- local num = 1
- while (num < 17)do
- local numItems = turtle.getItemCount(num)
- if(numItems > 0)then
- turtle.select(num)
- local data = turtle.getItemDetail()
- if (data)then
- if(data.name == itemName)then
- while(turtle.place() == false)do
- turtle.dig()
- end
- break
- end
- end
- end
- num = num + 1
- end
- end
- function placeUp()
- local slotNum = turtle.getSelectedSlot()
- if(turtle.placeUp() == false)then
- turtle.up()
- turtle.turnRight()
- local num = 1
- while (num < 17)do
- local numItems = turtle.getItemCount(num)
- if(numItems > 0)then
- turtle.select(num)
- local data = turtle.getItemDetail()
- if (data)then
- if(data.name == "minecraft:cobblestone" or data.name == "minecraft:stone")then
- turtle.place()
- break
- end
- end
- end
- num = num + 1
- end
- turtle.turnLeft()
- turtle.down()
- turtle.select(slotNum)
- turtle.placeUp()
- end
- end
- function enoughTorchesAndChests()
- local cnt = 1
- local tSuccess = false
- local cSuccess = false
- while (cnt < 17)do
- local numItems = turtle.getItemCount(cnt)
- if (numItems > 0)then
- turtle.select(cnt)
- local data = turtle.getItemDetail()
- if (data)then
- if (data.name == "minecraft:torch" and numItems > 2)then
- tSuccess = true
- elseif (data.name == "minecraft:chest")then
- cSuccess = true
- end
- if (tSuccess and cSuccess)then
- return
- end
- end
- end
- cnt = cnt + 1
- end
- if (tSuccess == false)then
- print("You need 3 or more torches")
- print("Press enter to continue")
- io.read()
- enoughTorchesAndChests()
- return
- end
- if (cSuccess == false)then
- print("You need 1 or more chests")
- print("Press enter to continue")
- io.read()
- enoughTorchesAndChests()
- end
- end
- function haveEnoughFuel()
- if(turtle.getFuelLevel() < 100)then
- while(fuelWithOwnRessources() == false)do
- print("Please give some fuel to this turtle! After that press enter!")
- io.read()
- end
- end
- return true
- end
- function fuelWithOwnRessources()
- local slotsLeft = 16
- while (slotsLeft > 0)do
- local cntItem = turtle.getItemCount()
- if (cntItem > 0)then
- turtle.select(17 - slotsLeft)
- turtle.refuel()
- if (turtle.getFuelLevel() >= 100)then
- return true
- end
- end
- slotsLeft = slotsLeft - 1
- end
- return false
- end
- print("At which side do you make the strip mine tunnels?")
- print("Enter 1 for right, or any other number for left")
- local side = tonumber(io.read())
- local num = 0
- while (num < numTunnels)do
- enoughTorchesAndChests()
- local num1 = 1
- while (num1 <= tunLength)do
- turtleForward()
- num1 = num1 + 1
- end
- num1 = 1
- turnAround()
- placeItemUp("minecraft:torch")
- while (num1 <= tunLength)do
- if (num1 ~= 30 and num1 % 10 == 0)then
- placeItemUp("minecraft:torch")
- end
- turtle.forward()
- num1 = num1 + 1
- end
- if(side == 1)then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- placeItem("minecraft:chest")
- num1 = 1
- while(num1 < 17)do
- local numItems = turtle.getItemCount(num1)
- if (numItems > 0)then
- turtle.select(num1)
- local data = turtle.getItemDetail()
- if (data)then
- if (data.name ~= "minecraft:torch" and data.name ~= "minecraft:chest")then
- turtle.drop()
- end
- end
- end
- num1 = num1 + 1
- end
- if(num < numTunnels - 1)then
- turnAround()
- turtleForward()
- turtleForward()
- turtleForward()
- if (side == 1)then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- end
- num = num + 1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement