Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function shaft()
- --main shaft
- term.clear()
- term.setCursorPos(1,1)
- print("Digging shaft")
- count = 0
- branchcount = 0
- --for count = 0, tonumber(mainshaft) do
- repeat
- turtle.dig()
- if turtle.forward() then
- count = count + 1
- branchcount = branchcount + 1
- end
- turtle.digUp()
- if branchcount == 4 then --branch clause
- print("Branching!")
- branch()
- branchcount = 0
- end
- --reset variables
- percent() --percent complete clause
- until count == tonumber(mainshaft)
- --end
- --final inv check
- finalinv()
- count = 0
- end
- function branch()
- --branch
- --left first
- local torchplace = 0
- local turtlereturnleft = 0
- local turtlereturnright = 0
- turtle.turnLeft()
- local branchleftcount = 0
- repeat
- --for branchleftcount = 0, tonumber(branchshaft) do
- turtle.dig()
- --turtle.forward()
- if turtle.forward() then
- turtlereturnleft = turtlereturnleft + 1
- branchleftcount = branchleftcount + 1
- end
- turtle.digUp()
- --end
- until branchleftcount == tonumber(branchshaft)
- turtle.turnLeft()
- turtle.turnLeft()
- repeat
- turtle.dig()
- -- turtle.forward()
- if turtle.forward() then
- turtlereturnleft = turtlereturnleft - 1
- torchplace = torchplace + 1
- end
- if placetorches == true then
- if torchplace == 5 then
- if turtle.getItemCount(1) > 1 then -- don't want to run out of torches. will fill tunnel with random block (in slot 1)
- turtle.select(1) --select torches
- turtle.placeUp()
- torchplace = 0
- else
- print("Torch supply low")
- end
- end
- end
- --turtle.digUp()
- until turtlereturnleft == 0
- --right now
- torchplace = 0
- local branchrightcount = 0
- repeat
- -- for branchrightcount = 0, tonumber(branchshaft) do --UNCOMMENT THIS AND 56 FOR OLD SYSTEM
- turtle.dig()
- --turtle.forward()
- if turtle.forward() then
- turtlereturnright = turtlereturnright + 1
- branchrightcount = branchrightcount + 1
- end
- turtle.digUp()
- until branchrightcount == tonumber(branchshaft)
- --end --UNCOMMENT THIS AND 48 FOR OLD SYSTEM
- turtle.turnLeft()
- turtle.turnLeft()
- repeat
- turtle.dig()
- -- turtle.forward()
- if turtle.forward() then
- turtlereturnright = turtlereturnright - 1
- torchplace = torchplace + 1
- end
- if placetorches == true then
- if torchplace == 5 then
- if turtle.getItemCount(1) > 1 then -- don't want to run out of torches. will fill tunnel with random block (in slot 1)
- turtle.select(1) --select torches
- turtle.placeUp()
- torchplace = 0
- else
- print("Torch supply low")
- end
- end
- end
- -- turtle.digUp()
- until turtlereturnright == 0
- turtle.turnRight()
- print("Finished Branching!")
- if usechest == true then
- invcheck() -- CHECK INVENTORY
- end
- end
- function invcheck()
- --inventory checking
- print("Checking Inventory...")
- if turtle.getItemCount(16) ~= 0 then
- print("Ejecting Inventory!")
- turtle.select(2)
- if turtle.placeUp then
- turtle.digUp()
- turtle.placeUp()
- turtle.select(3)
- turtle.dropUp()
- turtle.select(4)
- turtle.dropUp()
- turtle.select(5)
- turtle.dropUp()
- turtle.select(6)
- turtle.dropUp()
- turtle.select(7)
- turtle.dropUp()
- turtle.select(8)
- turtle.dropUp()
- turtle.select(9)
- turtle.dropUp()
- turtle.select(10)
- turtle.dropUp()
- turtle.select(11)
- turtle.dropUp()
- turtle.select(12)
- turtle.dropUp()
- turtle.select(13)
- turtle.dropUp()
- turtle.select(14)
- turtle.dropUp()
- turtle.select(15)
- turtle.dropUp()
- turtle.select(16)
- turtle.dropUp()
- --print("Dropped 3x3 Area! Transferring for next check!")
- -- MOVING ITEMS
- -- turtle.select(4)
- -- turtle.transferTo(3)
- -- turtle.select(8)
- -- turtle.transferTo(5)
- -- turtle.select(12)
- -- turtle.transferTo(6)
- -- turtle.select(13)
- -- turtle.transferTo(7)
- -- turtle.select(14)
- -- turtle.transferTo(9)
- -- turtle.select(15)
- -- turtle.transferTo(10)
- -- turtle.select(16)
- -- turtle.transferTo(11)
- print("Transferred Inventory! Collecting Chest!")
- turtle.select(2)
- turtle.digUp()
- else
- turtle.digUp()
- turtle.placeUp()
- turtle.select(3)
- turtle.dropUp()
- --turtle.select(4)
- --turtle.dropUp()
- turtle.select(5)
- turtle.dropUp()
- turtle.select(6)
- turtle.dropUp()
- turtle.select(7)
- turtle.dropUp()
- --turtle.select(8)
- --turtle.dropUp()
- turtle.select(9)
- turtle.dropUp()
- turtle.select(10)
- turtle.dropUp()
- turtle.select(11)
- turtle.dropUp()
- --turtle.select(12)
- --turtle.dropUp()
- --turtle.select(13)
- --turtle.dropUp()
- --turtle.select(14)
- --turtle.dropUp()
- --turtle.select(15)
- --turtle.dropUp()
- --turtle.select(16)
- --turtle.dropUp()
- print("Dropped 3x3 Area! Transferring for next check!")
- -- MOVING ITEMS
- turtle.select(4)
- turtle.transferTo(3)
- turtle.select(8)
- turtle.transferTo(5)
- turtle.select(12)
- turtle.transferTo(6)
- turtle.select(13)
- turtle.transferTo(7)
- turtle.select(14)
- turtle.transferTo(9)
- turtle.select(15)
- turtle.transferTo(10)
- turtle.select(16)
- turtle.transferTo(11)
- print("Dropped Inventory! Collecting Chest!")
- turtle.select(2)
- turtle.digUp()
- end
- else
- print("Inventory Fine!")
- end
- end
- function finalinv()
- print("Excreting inventory!")
- sleep(1)
- turtle.digUp()
- turtle.select(2)
- turtle.digUp()
- turtle.placeUp()
- turtle.select(3)
- turtle.dropUp()
- sleep(1)
- turtle.select(4)
- turtle.dropUp()
- sleep(1)
- turtle.select(5)
- turtle.dropUp()
- sleep(1)
- turtle.select(6)
- turtle.dropUp()
- sleep(1)
- turtle.select(7)
- turtle.dropUp()
- sleep(1)
- turtle.select(8)
- turtle.dropUp()
- sleep(1)
- turtle.select(9)
- turtle.dropUp()
- sleep(1)
- turtle.select(10)
- turtle.dropUp()
- sleep(1)
- turtle.select(11)
- turtle.dropUp()
- sleep(1)
- turtle.select(12)
- turtle.dropUp()
- sleep(1)
- turtle.select(13)
- turtle.dropUp()
- sleep(1)
- turtle.select(14)
- turtle.dropUp()
- sleep(1)
- turtle.select(15)
- turtle.dropUp()
- sleep(1)
- turtle.select(16)
- turtle.dropUp()
- sleep(1)
- print("Done!")
- end
- function percent()
- --percentage completion
- local percent = count/mainshaft*100
- --print( ..count.. " of " ..mineshaft.. )
- print("Percent Complete:" ..percent.. "%")
- end
- print("Branch Miner")
- print("Type begin to begin")
- local confirm = read()
- if confirm == "begin" then
- print("How long should the main shaft be? Default: 64")
- mainshaft = read()
- print("Digging the main shaft " ..mainshaft.. " blocks long")
- sleep(1)
- print("How long should branches be? Default: 32")
- branchshaft = read()
- print("Digging the branch shafts " ..branchshaft.. " blocks long")
- -- TORCHES
- print("Place Torches? (y/n)")
- local torches = read()
- if torches == "y" then
- print("Torches MUST be in slot 1! I will (try) to place them!")
- placetorches = true
- end
- --ENDERCHEST
- print("Use Ender Chests to empty inventory? (y/n)")
- local chests = read()
- if chests == "y" then
- print("Currently WIP. Place chest in slot 2!")
- usechest = true
- end
- sleep(1)
- print("Confirm? (write confirm)")
- local confirm2 = read()
- if confirm2 == "confirm" then
- term.clear()
- shaft()
- else
- print("Shutting Down...")
- sleep(0.5)
- os.shutdown()
- end
- else
- print("Shutting down...")
- os.shutdown()
- end
Advertisement
Add Comment
Please, Sign In to add comment