Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ShaftMiner 1.52c
- As seen in The ComputerCraft Challenge [youtube.com/bwochinski]
- Changes made by LazyNub to original
- Trash Cleanup added 5-5-13
- fourth trash choice added 5-5-13
- Changed Trashdump to 15lvl intervals 5-6-13
- Made 1st slot cover material 5-6-13
- Removed cover material slot option 5-6-13
- Changed Trashdump to 30lvl intervals 5-10-13
- Added Inventory Compressor Function every 10 lvls 5-10-13
- (Based on code from ProfessionalProcrastinator http://pastebin.com/YK2tVjRM)
- This program will mine in vertical shafts down to bedrock, checking the walls of the shaft.
- Shafts are staggered so the turtle will view every block if the pattern is continued.
- Set "consoleID" to the id of a computer listening on rednet to get remote status messages.
- ** Prep the Turtle before running! **
- Slots 1,2,3,4 are for blocks not to mine (smooth stone, gravel, dirt, cobble)
- Slot 1 is also the block to backfill holes (recommend cobble)
- Slot 16 is for fuel only
- ]]--
- depth = 0
- runs = 0
- function fuel()
- if turtle.getFuelLevel() <= depth + 10 then
- if not turtle.getItemCount(16) then
- print("Running out of fuel")
- end
- turtle.select(16)
- turtle.refuel(1)
- end
- end
- function isValuable()
- if turtle.detect() == false then
- return false
- end
- for i=1,4 do
- turtle.select(i)
- if turtle.compare() then
- return false
- end
- end
- turtle.select(1)
- return true
- end
- function compressInv()
- print ("Compressing")
- for i = 1,15 do
- if turtle.getItemCount(i) > 0 and turtle.getItemCount(i) < 64 then
- turtle.select(i)
- for j = i+1,15 do
- if turtle.compareTo(j) then
- turtle.select(j)
- turtle.transferTo(i)
- turtle.select(i)
- end
- end
- end
- end
- for i = 5,15 do
- if turtle.getItemCount(i) > 0 then
- for j = 5,i do
- if turtle.getItemCount(j) == 0 then
- turtle.select(i)
- turtle.transferTo(j)
- break
- end
- end
- end
- end
- for i = 5,15 do
- turtle.select(16)
- if turtle.compareTo(i) then
- turtle.select(i)
- turtle.transferTo(16)
- end
- end
- print ("Compressed")
- end
- function dumptrash()
- for tr=5,15 do
- turtle.select(tr)
- for i=1,4 do
- if turtle.compareTo(i) then
- turtle.dropDown()
- if isWireless then
- rednet.broadcast("Droped Trash At depth "..depth)
- end
- end
- end
- end
- for i=1,4 do
- turtle.select(i)
- if turtle.getItemCount(i)>8 then
- turtle.dropDown(turtle.getItemCount(i)-8)
- end
- end
- turtle.select(1)
- end
- function checkWalls(dp)
- for j=1,4 do
- if isValuable() then
- turtle.dig()
- end
- turtle.turnRight()
- end
- end
- ------ ( Program Start ) ------
- term.clear()
- term.setCursorPos(1,1)
- print("Ben's Simple Turtle Miner")
- print("-------------------------")
- print(" Mods made by LazyNub")
- print("-------------------------")
- term.write("How many runs in to start: ")
- runs = read() * 1
- print("\n")
- term.write("How many runs to mine: ")
- runcount = read() * 1
- print("\n")
- runcount = runs + runcount
- while runs < runcount do
- limruns = runs*2
- for dee=1,limruns do
- fuel()
- while not turtle.forward() do
- turtle.dig()
- sleep(.8)
- end
- while not turtle.forward() do
- turtle.dig()
- sleep(.8)
- end
- turtle.turnRight()
- while not turtle.forward() do
- turtle.dig()
- sleep(.8)
- end
- turtle.turnLeft()
- end
- depth = 0
- print("Commencing mining.")
- fuel()
- turtle.digDown()
- for st=1,2 do
- turtle.down()
- depth = depth + 1
- print("Current Depth "..depth)
- turtle.digDown()
- end
- -- plug entrance hole
- turtle.select(1)
- turtle.placeUp()
- while not turtle.detectDown() do
- fuel()
- turtle.down()
- depth = depth + 1
- print("Current Depth "..depth)
- if isWireless and depth%10==0 then
- rednet.broadcast("At depth "..depth)
- end
- if depth%10==0 then
- compressInv()
- end
- if depth%30==0 then
- dumptrash()
- end
- checkWalls(depth)
- turtle.digDown()
- end
- for mv=1,6 do
- fuel()
- turtle.up()
- depth = depth - 1
- print("Current Depth "..depth)
- end
- -- move forward 2 blocks
- print("Moving to upward shaft")
- for z=1,2 do
- fuel()
- while not turtle.forward() do
- turtle.dig()
- sleep(.8)
- end
- end
- -- turn right and move one block
- turtle.turnRight()
- fuel()
- while not turtle.forward() do
- turtle.dig()
- sleep(.8)
- end
- turtle.turnLeft()
- -- go down to bedrock
- turtle.digDown()
- while not turtle.detectDown() do
- fuel()
- turtle.select(1)
- turtle.down()
- depth = depth + 1
- turtle.digDown()
- print("Current Depth "..depth)
- end
- print("Digging up second shaft")
- for k=depth,3,-1 do
- checkWalls(k)
- turtle.digUp()
- fuel()
- print("Current Depth "..k)
- if k%10==0 then
- compressInv()
- end
- if k%30==0 then
- dumptrash()
- end
- while not turtle.up() do
- turtle.digUp()
- sleep(.5)
- end
- end
- dumptrash()
- fuel()
- turtle.digUp()
- turtle.up()
- turtle.digUp()
- turtle.up()
- -- fill exit hole
- turtle.select(1)
- turtle.placeDown()
- limitruns = runs*2 + 1
- runs = runs + 1;
- turtle.turnLeft()
- turtle.turnLeft()
- for deez=1,limitruns do
- fuel()
- turtle.turnRight()
- while not turtle.forward() do
- turtle.dig()
- sleep(.8)
- end
- turtle.turnLeft()
- while not turtle.forward() do
- turtle.dig()
- sleep(.8)
- end
- while not turtle.forward() do
- turtle.dig()
- sleep(.8)
- end
- end
- for bal=5,15 do
- turtle.select(bal)
- turtle.drop()
- end
- turtle.turnRight()
- turtle.turnRight()
- end
- print("Cancelled mining.")
Advertisement
Add Comment
Please, Sign In to add comment