Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("version")
- sleep(2)
- print("AutoMiner by theTANCO "..version.versionnum)
- sleep(4)
- print("")
- mine = true
- blocknum = 0
- j = 0
- i = 0
- function continue()
- cont = true
- while cont == true do
- print('Type "s" to shutdown, "r" to see fuel or refuel, or "c" to continue mining.')
- key = read()
- print("")
- if key == "s" or key == "S" then
- cont = false
- mine = false
- shell.run("shutdown")
- elseif key == "r" or key == "R" then
- turtle.select(16)
- turtle.refuel()
- print("Fuel level: "..turtle.getFuelLevel())
- print("To refuel, put a fuel item such as coal in item slot 16.")
- sleep(1)
- print("")
- elseif key == "c" or key == "C" then
- cont = false
- check()
- else
- print("Please type a specified letter.")
- sleep(1)
- print("")
- end
- end
- end
- function torches()
- if turtle.getItemCount(1) == 0 then
- print("Not enough torches to continue.")
- print("Please place more torches in item slot 1 to continue.")
- print("")
- sleep(1)
- continue()
- end
- end
- function fuel()
- if turtle.getFuelLevel() == 0 then
- print("Not enough fuel to continue.")
- print("Please place fuel items such as coal in item slot 16 to refuel.")
- print("")
- sleep(1)
- continue()
- end
- end
- function inventory()
- f = false
- while true do
- for q=1,16 do
- if turtle.getItemCount(q) > 0 then
- inv = {}
- inv[q-1] = true
- else
- inv[q-1] = false
- f = true
- break
- end
- end
- if f == false then
- turtle.turnLeft()
- turtle.turnLeft()
- return = j*9+i+1
- returning = return
- while returning > 0 do
- turtle.forward()
- returning = returning - 1
- end
- for r=3,15 do
- turtle.select(r)
- turtle.drop(64)
- end
- turtle.turnLeft()
- turtle.turnLeft()
- while returning < return do
- turtle.forward()
- returning = returning + 1
- end
- else
- break
- end
- end
- end
- function check()
- torches()
- fuel()
- end
- continue()
- while mine == true do
- turtle.select(1)
- inputCheck1 = true
- while inputCheck1 == true do
- print("Mine for how many blocks?")
- print("Your input will be rounded down to a multiple of 9.")
- h=math.floor(read()/9)
- blocknum = h*9
- inputCheck2 = true
- while inputCheck2 == true do
- print("")
- textutils.slowPrint("Mining for "..blocknum.." blocks ("..h.." torches).")
- textutils.slowPrint('Type "go" to start or "stop" to retype your input.')
- confirmInput = read()
- print("")
- if confirmInput == "go" then
- inputCheck1 = false
- inputCheck2 = false
- elseif confirmInput == "stop" then
- inputCheck2 = false
- end
- end
- end
- textutils.slowPrint("Mining...")
- sleep(3)
- for j=1,h do
- check()
- for i=1,9 do
- inventory()
- while turtle.detect() == true do
- turtle.dig()
- sleep(0.5)
- end
- check()
- turtle.forward()
- turtle.digDown()
- turtle.turnLeft()
- turtle.select(2)
- turtle.placeUp()
- turtle.place()
- check()
- turtle.down()
- turtle.place()
- turtle.placeDown()
- turtle.turnRight()
- turtle.turnRight()
- turtle.place()
- check()
- turtle.up()
- turtle.place()
- turtle.turnLeft()
- end
- turtle.select(2)
- turtle.place()
- check()
- turtle.down()
- turtle.place()
- check()
- turtle.up()
- turtle.select(1)
- turtle.placeDown()
- print("Placed "..j.."/"..h.." torches.")
- end
- print("Finished mining.")
- turtle.turnLeft()
- turtle.turnLeft()
- for k=1,blocknum do
- check()
- turtle.forward()
- end
- turtle.select(2)
- turtle.digDown()
- turtle.placeDown()
- check()
- turtle.forward()
- for l=3,15 do
- turtle.select(l)
- turtle.drop(64)
- end
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(1)
- turtle.place()
- print("")
- sleep(1)
- continue()
- end
- shell.run("shutdown")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement