Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------
- -- Efficient Quarry --
- -- Made By Vilsol --
- -- 1/20/2012 --
- ----------------------
- term.clear()
- term.setCursorPos(1, 1)
- tArgs = { ... }
- depth = 0
- left = false
- if(tArgs[1] == "update")then
- shell.run("rm", "eQuarry")
- shell.run("pastebin", "get", "PMfpn37Z", "eQuarry")
- print "Update successfull!"
- error()
- end
- function bringHome()
- turtle.digUp()
- turtle.select(13)
- turtle.placeUp()
- for slots = 1, 12 do
- turtle.select(slots)
- if(turtle.getItemCount(slots) > 0)then
- turtle.dropUp()
- end
- end
- turtle.select(13)
- turtle.digUp()
- turtle.select(1)
- end
- function isFull()
- slot = turtle.getItemCount(12)
- if(slot >= 1)then
- bringHome()
- end
- end
- function checkSlots()
- enderchest = turtle.getItemCount(13)
- dirt = turtle.getItemCount(14)
- stone = turtle.getItemCount(15)
- fuel = turtle.getItemCount(16)
- if(enderchest == 1 and dirt == 1 and stone == 1 and fuel >= 1)then
- return true
- else
- return false
- end
- end
- function checkFuel()
- if(turtle.getFuelLevel() < 100)then
- turtle.select(16)
- if (turtle.refuel())then
- print "Refueled successfully"
- return true
- else
- print "Out of fuel!"
- error()
- end
- turtle.select(1)
- else
- return true
- end
- end
- function safeDig()
- isFull()
- if(not turtle.dig())then
- if(not turtle.detect())then
- return true
- else
- if(turtle.attack())then
- for attack = 1, 50 do
- turtle.attack()
- if(turtle.dig())then
- dig = 1
- break
- end
- sleep(0.1)
- end
- if dig then
- dig = 0
- return true
- else
- print "Unknown problem!"
- error()
- end
- else
- print "Unknown problem!"
- error()
- end
- end
- else
- return true
- end
- end
- function safeForward()
- isFull()
- if(not turtle.forward())then
- sleep(1)
- if(turtle.attack())then
- for attack = 1, 50 do
- turtle.attack()
- if(turtle.forward())then
- forward = 1
- break
- end
- sleep(0.1)
- end
- if forward then
- forward = 0
- return true
- else
- print "Unknown problem!"
- error()
- end
- else
- if(turtle.dig())then
- sleep(1)
- for graveler = 1, 8 do
- if(not turtle.dig())then
- break
- end
- sleep(1)
- end
- if(turtle.forward())then
- return true
- else
- print "Unknown problem!"
- error()
- end
- else
- print "Unknown problem!"
- error()
- end
- end
- else
- return true
- end
- end
- function compareOre()
- digup = 0
- digdown = 0
- turtle.select(14)
- if not turtle.compareUp() then
- digup = 1
- end
- if not turtle.compareDown() then
- digdown = 1
- end
- turtle.select(15)
- if not turtle.compareUp() then
- digup = digup + 1
- end
- if not turtle.compareDown() then
- digdown = digdown + 1
- end
- turtle.select(1)
- if(digup == 2)then turtle.digUp() end
- if(digdown == 2)then turtle.digDown() end
- end
- function turn()
- if left then
- left = false
- turtle.turnLeft()
- safeDig()
- safeForward()
- turtle.turnLeft()
- else
- left = true
- turtle.turnRight()
- safeDig()
- safeForward()
- turtle.turnRight()
- end
- end
- function checkLayer(x, z)
- for widthz = 1, z do
- for heightx = 1, x do
- compareOre()
- safeDig()
- safeForward()
- end
- compareOre()
- if tonumber(widthz) < tonumber(z) then
- turn()
- end
- end
- if left then
- turtle.turnRight()
- for back = 1, z-1 do
- safeForward()
- end
- turtle.turnRight()
- else
- turtle.turnLeft()
- for back = 1, z-1 do
- safeForward()
- end
- turtle.turnLeft()
- for back = 1, x do
- safeForward()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- end
- left = false
- end
- function backUp()
- for up = 1, y do
- turtle.up()
- end
- end
- function digQuarry(x, z, y)
- while true do
- checkLayer(x, z)
- for down = 1, 3 do
- depth = depth + 1
- turtle.digDown()
- turtle.down()
- end
- if(depth >= y)then
- backUp()
- print "Done!"
- break
- end
- end
- end
- if(#tArgs < 3)then
- print "Usage: eQuarry x z y"
- error()
- else
- x = tonumber(tArgs[1]) - 1
- z = tonumber(tArgs[2])
- y = tonumber(tArgs[3])
- if(tonumber(x) and tonumber(z) and tonumber(y))then
- if(true)then
- if(checkFuel())then
- print ("Digging a " .. x+1 .. "x" .. z .. "x" .. y .. " quarry!")
- digQuarry(x, z, y)
- else
- print "Something went very wrong!"
- error()
- end
- else
- print "Please fill in the slot as follows:"
- print "Slot 13: Enderchest for dumping items."
- print "Slot 14: Dirt"
- print "Slot 15: Stone"
- print "Slot 16: Fuel"
- error()
- end
- else
- print "Please use only numbers!"
- error()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement