Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --=======================================Standard Lbrary=====================================--
- function smartFuel()
- if turtle.getFuelLevel() <= 0 then
- onSlot = turtle.getSelectedSlot()
- while not turtle.refuel(1) do
- onSlot = onSlot + 1
- if onSlot == 17 then
- onSlot = 1
- end
- turtle.select(onSlot)
- end
- end
- end
- function smartFor()
- while not turtle.forward() do
- turtle.attack()
- turtle.dig()
- smartFuel()
- end
- end
- function smartUp()
- while not turtle.up() do
- turtle.attackUp()
- turtle.digUp()
- smartFuel()
- end
- end
- function smartDown()
- while not turtle.down() do
- turtle.attackDown()
- turtle.digDown()
- smartFuel()
- cleanse()
- end
- end
- function smartMove(dir)
- if dir == -1 then
- turtle.turnLeft()
- smartFor()
- elseif dir == 1 then
- turtle.turnRight()
- smartFor()
- elseif dir == 2 then
- smartFor()
- elseif dir == -2 then
- turtle.turnRight()
- turtle.turnRight()
- smartFor()
- elseif dir == 3 then
- smartUp()
- elseif dir == -3 then
- smartDown()
- end
- end
- --=======================================Quarry Functions=====================================--
- --======inputVars======--
- function inputVars()
- print("Enter Approx. height")
- CHUNKS = tonumber(read())/4
- print("Enter approx. width")
- PITS = tonumber(read())/5
- print("Enter Dive (Amount to go down before starting)")
- DIVE = tonumber(read())
- print("Enter Depth")
- DEPTH = tonumber(read())
- coalEstimate = math.ceil(((((((6+(DEPTH*2))*CHUNKS)*2)*PITS)+(DIVE*2))/80)*1.1)
- print("This quarry will require approximately " .. tostring(coalEstimate) .. " coal to complete. Is what you entered correct? Enter 'N' to re enter input, or any other button to start quarry")
- if read() == "N" then
- inputVars()
- end
- end
- DEPTH = 1
- --how deep do I go before I start the quarry?
- DIVE = 0
- --which ores not to mine
- blackList = {"minecraft:stone","minecraft:grass","minecraft:dirt","minecraft:sand","minecraft:gravel","minecraft:sandstone","minecraft:cobblestone"}
- --copper, uran,yellorite,marble,tin,lead, alu, silver, quartz
- --======dump======--
- function dump()
- for x = 1,16 do
- itemData = turtle.getItemDetail(x)
- if itemData then
- if onBlackList(itemData.name) then
- turtle.select(x)
- turtle.drop()
- end
- end
- end
- end
- --======hasRoom======--
- --returns if no slot is empty
- function hasRoom()
- for x = 1,16 do
- if turtle.getItemCount(x) == 0 then
- return true
- end
- end
- return false
- end
- --======onBlackList======--
- function onBlackList(target)
- for z = 0,table.getn(blackList) do
- if target == blackList[z] then
- return true
- end
- end
- return false
- end
- --======smartComp======--
- function smartComp()
- local sucess, data = turtle.inspect()
- if sucess then
- if not onBlackList(data.name) then
- turtle.dig()
- end
- end
- end
- --=====dropAll======--
- --excludes slot 2, saved for fuel
- function dropAll()
- for c = 3, 16 do
- turtle.select(c)
- turtle.drop()
- end
- end
- --======Store======--
- function store()
- turtle.dig()
- turtle.select(1)
- turtle.place()
- dropAll()
- turtle.select(1)
- turtle.dig()
- end
- --======cleanse======--
- function cleanse()
- data = turtle.getItemDetail(16)
- if data then
- dump()
- --store()
- end
- end
- --======smartMine======--
- function smartMine(dir)
- smartMove(3*dir)
- smartComp()
- turtle.turnRight()
- smartComp()
- turtle.turnRight()
- smartComp()
- turtle.turnRight()
- smartComp()
- turtle.turnRight()
- end
- --======Scale======--
- --must be facing "east"
- function scale(dir)
- for i = 0, DEPTH, 1 do
- if dir == -1 then
- smartMine(-1)
- elseif dir == 1 then
- smartMine(1)
- end
- end
- smartMove(1)
- smartMove(-1)
- smartMove(2)
- end
- --======chunk(2 holes in the ground)======--
- function chunk()
- scale(-1)
- scale(1)
- end
- --======Slice(a line of some chunks)======--
- --1 is west, -1 is east
- function slice(dir)
- for j = 0,CHUNKS-1 do
- chunk()
- end
- if dir == 1 then
- smartMove(-1)
- smartMove(2)
- smartMove(2)
- smartMove(-1)
- elseif dir == -1 then
- smartMove(1)
- smartMove(2)
- smartMove(1)
- end
- end
- --======goBack======--
- function goBack()
- smartMove(1)
- for v = 1, (PITS*5)-1 do
- smartMove(2)
- end
- end
- --======pit(one or more slices)======--
- function pit()
- slice(1)
- slice(-1)
- end
- --===================Function Start========================-
- inputVars()
- for i = 1, DIVE do
- smartMove(-3)
- end
- for l = 1, PITS do
- pit()
- end
- goBack()
- for i = 1, DIVE do
- smartMove(3)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement