Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- depth = 0
- function status(msg)
- if isWireless then
- rednet.broadcast(msg)
- end
- term.print(msg)
- end
- function dropLoot(r)
- if r~=nil then
- turtle.turnRight()
- turtle.turnRight()
- end
- for i=1,4 do
- turtle.select(i)
- turtle.drop(turtle.getItemCount(i)-1)
- end
- for i=5,14 do
- turtle.select(i)
- turtle.drop(turtle.getItemCount(i))
- end
- if r~=nil then
- turtle.turnRight()
- turtle.turnRight()
- end
- turtle.select(1)
- end
- function fuel()
- if turtle.getFuelLevel() <= depth + 10 then
- turtle.select(16)
- turtle.refuel(1)
- status("Refueled. Fuel level: "..turtle.getFuelLevel())
- 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
- return true
- end
- function checkWalls(dp)
- for j=1,4 do
- if isValuable() then
- status("Ore at depth "..dp)
- turtle.select(1)
- turtle.dig()
- end
- turtle.turnRight()
- end
- end
- ------ ( Program Start ) ------
- sSide = nil
- if sSide == nil then
- for n,sMonitorSide in ipairs(rs.getSides()) do
- if peripheral.isPresent(sMonitorSide) and peripheral.getType(sMonitorSide) == "modem" then
- sSide = sMonitorSide
- break
- end
- end
- if not sSide then
- print( "No modem attached" )
- end
- if sSide ~= nil then
- if rednet.open("right") == true then
- isWireless = true
- end
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- print(os.getComputerLabel().." : "..turtle.getFuelLevel().." | Simple Turtle Miner")
- print("-------------------------")
- term.write("Start Mining? (y/n): ")
- while read() == "y" do
- depth = 0
- print("Commencing mining.")
- status(os.getComputerLabel().." : Commencing mining.")
- fuel()
- turtle.digDown()
- for st=1,2 do
- turtle.down()
- depth = depth + 1
- turtle.digDown()
- end
- -- plug entrance hole
- turtle.select(15)
- turtle.placeUp()
- while not turtle.detectDown() do
- fuel()
- turtle.down()
- depth = depth + 1
- if depth%5 == 0 then
- status("Depth "..depth.." DN")
- end
- checkWalls(depth)
- turtle.digDown()
- end
- status("Moving to next shaft")
- for mv=1,6 do
- fuel()
- turtle.up()
- depth = depth - 1
- end
- -- move forward 2 blocks
- 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.down()
- depth = depth + 1
- turtle.digDown()
- end
- status("Returning to surface!")
- for k=depth,3,-1 do
- checkWalls(k)
- turtle.select(1)
- turtle.digUp()
- fuel()
- while not turtle.up() do
- turtle.select(1)
- turtle.digUp()
- sleep(.5)
- end
- if k%5 == 0 then
- status("Depth "..k.." UP")
- end
- end
- fuel()
- turtle.select(1)
- turtle.digUp()
- turtle.up()
- turtle.select(1)
- turtle.digUp()
- turtle.up()
- -- fill exit hole
- turtle.select(15)
- turtle.placeDown()
- turtle.select(1)
- turtle.dig()
- turtle.forward()
- turtle.select(1)
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- turtle.select(1)
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- print("Press enter to drop loot")
- r=read()
- dropLoot(r)
- print("F:"..turtle.getFuelLevel())
- term.write("Mine? (y/n): ")
- end
- print("Cancelled mining.")
Advertisement
Add Comment
Please, Sign In to add comment