Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local SLOT_ENDERCHEST = 1
- local SLOT_QUARRY = 2
- local SLOT_PRODUCER = 3
- local SLOT_BRIDGE = 4
- local SLOT_CONSUMER = 5
- local SLOT_SOLARPANEL = 6
- local MAX_QUARRY_TIME = 1800
- local tArgs = { ... }
- local select = turtle.select
- local dig = turtle.dig
- local digDown = turtle.digDown
- local digUp = turtle.digUp
- local place = turtle.place
- local placeDown = turtle.placeDown
- local placeUp = turtle.placeUp
- local down = turtle.down
- local up = turtle.up
- local turnLeft = turtle.turnLeft
- local turnRight = turtle.turnRight
- local drop = turtle.drop
- function forward(dist)
- dist = dist or 1
- for i=1,tonumber(dist) do
- local forward = turtle.forward()
- if (not forward and not turtle.up()) then
- return false
- else
- i = i - 1
- end
- end
- end
- function back(dist)
- dist = dist or 1
- for i=1,tonumber(dist) do
- local back = turtle.back()
- if (not forward and not turtle.up()) then
- return false
- else
- i = i - 1
- end
- end
- end
- function setupQuarry()
- turnLeft()
- select(SLOT_ENDERCHEST)
- placeUp()
- down()
- select(SLOT_QUARRY)
- placeUp()
- back()
- select(SLOT_PRODUCER)
- placeUp()
- back()
- select(SLOT_BRIDGE)
- placeUp()
- back()
- select(SLOT_CONSUMER)
- placeUp()
- back()
- select(SLOT_SOLARPANEL)
- placeUp()
- forward(4)
- end
- function emptyInv()
- for i=7,16 do
- select(i)
- drop()
- end
- end
- function teardownQuarry(delay)
- delay = delay or 30
- back(4)
- --select(SLOT_ENDERCHEST)
- --place()
- --emptyInv()
- --select(SLOT_ENDERCHEST)
- --dig()
- select(SLOT_SOLARPANEL)
- digUp()
- forward()
- select(SLOT_CONSUMER)
- digUp()
- forward()
- select(SLOT_BRIDGE)
- digUp()
- forward()
- select(SLOT_PRODUCER)
- digUp()
- sleep(tonumber(delay))
- forward()
- select(SLOT_QUARRY)
- digUp()
- up()
- select(SLOT_ENDERCHEST)
- digUp()
- turnRight()
- end
- function active()
- return (peripheral.call('top', 'isActive') == "true")
- end
- if #tArgs > 0 then
- teardownQuarry(1)
- end
- while true do
- forward(9)
- setupQuarry()
- if not active() then
- print("Error: Couldn't connect quarry as peripheral")
- teardownQuarry()
- break
- end
- local start = os.clock()
- while active() do
- sleep(5)
- if (os.clock() - start) > MAX_QUARRY_TIME then
- break
- end
- end
- teardownQuarry()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement