Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --ComputerCraft mining turtle program (CraftOS 1.5)
- --For placing in a mining "corridor" and sending the turles off on strip mine branches.
- --Functions
- function dig()
- while turtle.detect() == true do
- turtle.dig()
- sleep (0.7)
- end
- turtle.forward()
- turtle.digUp()
- turtle.up()
- turtle.digUp()
- turtle.down()
- end
- function torch()
- turtle.turnLeft()
- turtle.dig()
- turtle.select(16)
- turtle.place()
- turtle.turnRight()
- end
- function returning()
- while turtle.detect() == true do
- turtle.dig()
- sleep (0.7)
- end
- turtle.forward()
- end
- function round(r,d)
- local d = d or 1
- return math.floor((r + d / 2) / d * d)
- end
- -- Main Body --
- term.write("How far would you like to mine? ")
- input = read()
- fuelreq = input * 4
- sleep (1)
- print ("Fuel Required: "..fuelreq)
- sleep (1)
- print ("Current Fuel Level: "..turtle.getFuelLevel())
- local fuelshort = fuelreq - turtle.getFuelLevel()
- if turtle.getFuelLevel() - fuelreq < 0 then
- print ("Not enough fuel, please add " ..fuelshort.. " fuel into slot 1-15...")
- while turtle.getFuelLevel() < fuelreq do
- for x = 1,15 do
- turtle.select(x)
- turtle.refuel(64)
- x = x + 1
- end
- end
- end
- sleep (1)
- print ("Enough fuel for this trip")
- sleep (1)
- term.write ("Checking torch quantities")
- sleep (0.6)
- term.write (".")
- sleep (0.5)
- term.write (".")
- sleep (0.5)
- print (".")
- sleep (0.5)
- local torchneed = input / 10
- local torchreq = round(torchneed, 1)
- turtle.select(16)
- if turtle.getItemCount(16) < torchneed then
- print ("Not enough torches, please place "..torchreq - turtle.getItemCount(16).." more into slot 16..")
- while turtle.getItemCount(16) < torchreq do
- sleep (1)
- end
- end
- sleep (0.3)
- print ("Enough torches")
- sleep (0.8)
- print ("Proceeding to mine...")
- local tally = 0
- for tally = 1,input do
- dig()
- if tally % 10 == 0 then
- torch()
- end
- end
- print ("Returning Back...")
- turtle.turnRight()
- turtle.turnRight()
- local q = 0
- for q = 1,input do
- returning()
- end
- local e = 0
- for e = 1,16 do
- turtle.select(e)
- turtle.drop(64)
- e = e + 1
- end
- print ("Finished Mining!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement