Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("turtleForward.lua")
- -- Quarry Dimension Input and Mining Program
- -- Get the dimensions
- function input(newWidth, newLength, newDepth)
- width = newWidth
- length = newLength
- depth = newDepth
- fuelcost = 0
- end
- function setDepth(newDepth)
- depth = newDepth
- end
- -- Function to Mine to Depth
- function mineDepth()
- for i = 1, depth do
- turtle.digDown()
- turtle.down()
- end
- end
- function mineHeight()
- for j = 1, depth do
- turtle.digUp()
- turtle.up()
- end
- end
- -- Function to mine a layer
- function mine(width, length)
- down = true
- for i = 1, length do
- for j = 1, width do
- if down then
- mineDepth()
- down = false
- else
- mineHeight()
- down = true
- end
- turtleForward.moveForward()
- end
- if i < length then
- if i % 2 == 1 then
- if down then
- mineDepth()
- down = false
- else
- mineHeight()
- down = true
- end
- turtle.turnRight()
- turtleForward.moveForward()
- turtle.turnRight()
- else
- if down then
- mineDepth()
- down = false
- else
- mineHeight()
- down = true
- end
- turtle.turnLeft()
- turtleForward.moveForward()
- turtle.turnLeft()
- end
- end
- end
- end
- function toStart()
- if length % 2 == 1 then
- turtle.turnLeft()
- turtle.turnLeft()
- for i = 1, width do
- turtle.forward()
- end
- end
- turtle.turnRight()
- for j = 2, length do
- turtle.forward()
- end
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function isBlockBelow(blockName)
- if turtle.detectDown() then
- local success, blockInfo = turtle.inspectDown()
- if success and blockInfo.name == blockName then
- return true
- else
- return false
- end
- else
- return false
- end
- end
- -- Function to Mine to Depth
- function smartMineDepth(blockname)
- i = 1
- while i ~= depth do
- if turtle.down() then
- i = i + 1
- else
- if isBlockBelow(blockname) then
- turtle.digDown()
- else
- break
- end
- end
- end
- i = i - 1
- for j = 1, i do
- turtle.up()
- end
- end
- -- Function to mine a layer
- function smartMine(width, length, blockname)
- for i = 1, length do
- for j = 1, width do
- smartMineDepth(blockname)
- turtleForward.moveForward()
- end
- if i < length then
- if i % 2 == 1 then
- smartMineDepth(blockname)
- turtle.turnRight()
- turtleForward.moveForward()
- turtle.turnRight()
- else
- smartMineDepth(blockname)
- turtle.turnLeft()
- turtleForward.moveForward()
- turtle.turnLeft()
- end
- end
- end
- end
- function quarry(newWidth, newLength, newDepth)
- input(newWidth, newLength, newDepth)
- turtleForward.moveForward()
- mine(width, length)
- if down then
- mineDepth()
- mineHeight()
- down = false
- else
- mineHeight()
- down = true
- end
- toStart()
- end
- function smartQuarry(newWidth, newLength, newDepth, blockname)
- input(newWidth, newLength, newDepth)
- turtleForward.moveForward()
- smartMine(width, length, blockname)
- smartMineDepth(blockname)
- toStart()
- end
- function remoteMine(width, length, depth)
- invalid = true
- while invalid do
- if width == nil then
- return "width error"
- elseif length == nil then
- return "length error"
- elseif depth == nil then
- return "depth error"
- else
- invalid = false
- end
- end
- tw = width
- tl = length
- td = depth
- if tw == 0 then
- tw = 1
- end
- if tl == 0 then
- tl = 1
- end
- if td == 0 then
- td = 1
- end
- volume = tw * tl * td
- width = width - 1
- print("Volume: " .. volume .. " blocks")
- max = volume > 9000
- if not max then
- predictSimpleQuarry.predict(width, length, depth)
- fuelcost = predictSimpleQuarry.getFuelCost()
- if fuelcost > turtle.getFuelLevel() then
- return "fuel error"
- else
- simpleQuarry.quarry(width, length, depth)
- return "true"
- else
- return "volume error"
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement