Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Made by HDGamer14
- Alpha
- To Do:
- - feature to leave the diamonds for you to break with fourtan pick
- - squash more bugs
- --]]
- local dist,dist1,row,row1,torchs,debug,auto_refuel,direction,home_dist,home_distRow,home,miner,torchRow,torchDist,newRow
- debug = true
- auto_refuel = false
- function mine()
- turtle.digUp()
- turtle.dig()
- turtle.digDown()
- end
- function unload()
- turtle.turnRight()
- print ("Unloading items...")
- for n=1,15 do
- turtle.select(n)
- turtle.drop()
- end
- turtle.select(1)
- turtle.turnLeft()
- end
- function go_back()
- print("Resuming mining . . .")
- if home_dist == 0 then
- turtle.turnLeft()
- else
- for i=1,home_dist do
- turtle.back()
- end
- turtle.turnLeft()
- end
- for i=1,home_distRow do
- turtle.forward()
- end
- if direction == true then
- else
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- end
- turtle.suck()
- turtle.suckDown()
- end
- function fuel()
- if turtle.getFuelLevel() < home then
- print ("Out of fuel!")
- if auto_refuel == true then
- turtle.select(1)
- for f=1,14 do
- turtle.select(f)
- turtle.refuel(2)
- end
- turtle.select(1)
- if turtle.getFuelLevel() < home then
- go_home()
- fuel_me()
- go_back()
- end
- else
- go_home()
- fuel_me()
- go_back()
- end
- else
- end
- end
- function fuel_me()
- print ("Waiting for fuel . . .")
- turtle.select(1)
- repeat
- turtle.refuel(16)
- sleep(1)
- until turtle.getFuelLevel() > 180
- end
- function go_home()
- if debug == true then
- print("Go_home")
- print("dist: ", dist , " dist1: " , dist1)
- print("row: " , row , " row1: " , row1)
- else
- end
- home_dist = dist - dist1
- if direction == true then
- home_distRow = row - row1
- else
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- home_distRow = row - row1 + 1
- end
- for i=1,home_dist do
- turtle.back()
- end
- turtle.turnRight()
- if home_distRow == 0 then
- unload()
- else
- for j=1,home_distRow do
- turtle.forward()
- end
- unload()
- end
- end
- function new_row()
- print("Row = "..row1)
- if row1 == 1 then
- turtle.digUp()
- turtle.digDown()
- print("Finised mineing")
- else
- if debug == true then
- print("New_row")
- print("Row = "..row1)
- end
- if direction == true then
- turtle.turnLeft()
- if turtle.forward() == false then
- repeat
- turtle.attack()
- mine()
- sleep(0.3)
- until turtle.forward() == true
- end
- turtle.turnLeft()
- direction = false
- else
- turtle.turnRight()
- if turtle.forward() == false then
- repeat
- turtle.attack()
- mine()
- sleep(0.3)
- until turtle.forward() == true
- end
- turtle.turnRight()
- direction = true
- end
- dist1 = dist
- row1 = row1 - 1
- home = home + 1
- if torchs == true then
- torchDist = 0
- torchRow = torchRow + 1
- if torchRow == 8 then
- torchRow = 0
- end
- end
- end
- end
- function cycle()
- if debug == true then
- print ("Cycle")
- sleep(1)
- end
- if dist1 == 0 then
- if newRow == true then
- new_row()
- else
- turtle.digUp()
- turtle.digDown()
- print("Finised mineing")
- end
- else
- mine()
- if torchs == true then
- if torchRow == 0 then
- torchDist = torchDist + 1
- if torchDist == 5 then
- turtle.select(16)
- turtle.placeDown()
- turtle.select(1)
- torchDist = 0
- end
- end
- end
- dist1 = dist1 - 1
- if direction == true then
- home = home + 1
- else
- home = home - 1
- end
- if turtle.forward() == false then
- repeat
- turtle.attack()
- mine()
- sleep(0.3)
- until turtle.forward() == true
- end
- fuel()
- if turtle.getItemCount(14) > 0
- then
- go_home()
- go_back()
- end
- end
- if debug == true then
- print("TorchRow "..torchRow)
- print("TorchDist "..torchDist)
- print("Dist after "..dist1)
- print("")
- end
- end
- newRow = true
- --Get info
- shell.run("clear")
- print("How far you you like me to go?")
- dist=read()
- print("How many rows would you like me to mine?")
- row=read(number)
- if row == 1 then
- newRow = false
- end
- print("Would you like me to use torches? (yes/no)")
- torchs=read()
- if torchs == "yes" then
- print("Place torhes in slot 16")
- repeat
- sleep(1)
- until turtle.getItemCount(16) > 0
- torchs = true
- else
- torchs = false
- end
- if debug == true then
- print("")
- print ("I'm mineing "..dist.." blocks deep!")
- print ("I'm mineing "..row.." Row(s) over!")
- if torchs == true then
- print ("I will use torches!")
- else
- print ("I will not use torches!")
- end
- end
- dist1 = dist
- row1 = row
- home = 5
- direction = true
- miner = dist * row
- miner = miner + row
- torchRow = 0
- torchDist = 0
- -- Start Program
- repeat
- cycle()
- miner = miner - 1
- until miner == 0
- go_home()
- turtle.turnRight()
- turtle.select(16)
- turtle.drop()
- turtle.select(1)
- print("All Done :D")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement