Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shell.run("clear")
- local torch = turtle.getItemCount(1)
- local chests = turtle.getItemCount(2)
- local fuel = turtle.getFuelLevel()
- local dist = 0
- local retdist = 0
- local t = 0
- local name = os.getComputerLabel()
- local branches = 1
- function start()
- print ""
- print "Welcome to the autominer3000"
- print ""
- print "Please have torches in slot 1, chests in 2 and fuel in 3 upon startup."
- print ""
- print "Failure to do so may have unforeseen health risks."
- print ""
- text = "[" .. name .. "~] How deep do you want each branch? (Length) (1/99): "
- io.write(text)
- ll = io.read()
- if not tonumber(ll) then
- print ""
- print "Please enter a valid number"
- print ""
- start()
- else
- length = ll+1
- start_1()
- end
- if tonumber(length) < 1 then
- print ""
- print "Number must be positive"
- print ""
- start()
- end
- end
- function start_1()
- text = "[" .. name .. "~] How many branches do you want? (Width) (1/99): "
- io.write(text)
- w = io.read()
- if not tonumber(w) then
- print ""
- print "Please enter a valid number"
- print ""
- start_1()
- else
- width = w
- start_2()
- end
- if tonumber(w) < 1 then
- print ""
- print "Number must be positive"
- print ""
- start_1()
- end
- end
- function start_2()
- text = "[" .. name .. "~] Enderchest? (y/n): "
- io.write(text)
- e = io.read()
- if e == "y" then
- enderchest = true
- start_3()
- elseif e == "n" then
- enderchest = false
- start_3()
- else
- print ""
- print "Please enter y or n"
- print ""
- start_2()
- end
- end
- function start_3()
- text = "[" .. name .. "~] Direction (left/right): "
- io.write(text)
- d = io.read()
- if d == "left" then
- direction = d
- start_4()
- elseif d == "right" then
- direction = d
- start_4()
- else
- print ""
- print "Please enter y or n"
- print ""
- start_3()
- end
- end
- function start_4()
- print ("")
- print ("I will dig ".. w .. ", " .. ll .. " long tunnel(s)")
- print ("")
- if enderchest == true then
- print("Enderchest: Yes")
- else
- print("Enderchest: No")
- end
- print ("")
- print ("Making branches to the " .. direction)
- print ("")
- text = "[" .. name .. "~] Are you sure you want to procede? (y/n): "
- io.write(text)
- c = io.read()
- if c == "y" then
- --if check_items() then run() end
- run()
- elseif c == "n" then
- print "Be seeing you!"
- else
- print ""
- print "Please enter y or n"
- print ""
- start_4()
- end
- end
- function check_items()
- end
- function reFuel()
- for i = 3, 16 do
- turtle.select(i)
- turtle.refuel(1)
- if turtle.getFuelLevel() > 0 then
- turtle.select(1)
- local fuel = turtle.getFuelLevel()
- return
- end
- end
- addFuel()
- end
- function addFuel()
- print ""
- print "Add fuel to continue..."
- print ""
- turtle.select(3)
- while turtle.getFuelLevel() == 0 do
- turtle.refuel(1)
- sleep(1)
- end
- print ""
- print "Yummy, thank you!"
- print ""
- end
- function forward()
- if turtle.getFuelLevel() < 1 then
- reFuel()
- end
- if turtle.detect() then
- turtle.dig()
- sleep(.6)
- while turtle.detectUp() == true do
- turtle.digUp()
- sleep(.6)
- end
- end
- if turtle.forward() then
- dist = dist + 1
- end
- dump()
- turtle.digUp()
- print("dist:" .. dist)
- print("length:" .. length)
- print("branches:" .. branches)
- end
- function turn()
- if lastDirection == "right" then direction = "left" end
- if lastDirection == "left" then direction = "right" end
- if direction == "left" then
- turtle.turnLeft()
- forward()
- turtle.turnRight()
- turtle.turnRight()
- turtle.select(1)
- turtle.place()
- turtle.turnRight()
- turtle.turnRight()
- forward()
- forward()
- forward()
- turtle.turnLeft()
- lastDirection = "left"
- dist = 0
- branches = branches+1
- elseif direction == "right" then
- turtle.turnRight()
- forward()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(1)
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- forward()
- forward()
- forward()
- turtle.turnRight()
- lastDirection = "right"
- dist = 0
- branches = branches+1
- end
- end
- function dump()
- if turtle.getItemCount(16)>0 then
- turtle.digDown()
- turtle.select(2)
- turtle.placeDown()
- turtle.select(1)
- for slot = 4,16,1 do
- turtle.select(slot)
- turtle.dropDown()
- end
- turtle.select(1)
- if enderchest then
- turtle.select(2)
- turtle.digDown()
- else
- chests = chests - 1
- end
- end
- end
- function light()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(1)
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- torch = torch - 1
- t = 0
- end
- function run()
- while dist < tonumber(length) and branches <= tonumber(width) do
- t = t + 1
- if t == 12 then
- light()
- end
- forward()
- retdist = dist + 14
- local fuel = turtle.getFuelLevel()
- end
- if branches == tonumber(width) and dist == tonumber(length) then os.shutdown() end
- turn()
- run()
- end
- start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement