Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inPit = false
- loops = 0
- local function forward(count)
- if count == nil then count = 1 end
- for i = 1, count do
- res = turtle.forward()
- end
- return res
- end
- local function up(count)
- if count == nil then count = 1 end
- for i = 1, count do
- res = turtle.up()
- end
- return res
- end
- local function down(count)
- if count == nil then count = 1 end
- for i = 1, count do
- res = turtle.down()
- end
- return res
- end
- local function turnLeft(count)
- if count == nil then count = 1 end
- for i = 1, count do
- turtle.turnLeft()
- end
- return res
- end
- local function turnRight(count)
- if count == nil then count = 1 end
- for i = 1, count do
- res = turtle.turnRight()
- end
- return res
- end
- local function enterPit()
- forward(3)
- down()
- inPit = true
- return true
- end
- local function exitPit()
- turnLeft(2)
- up()
- forward(3)
- turnLeft(2)
- inPit = false
- return true
- end
- local function deposit()
- if inPit then
- exitPit()
- end
- turnLeft()
- turtle.up()
- forward(2)
- for i = 3,16 do
- turtle.select(i)
- turtle.dropDown()
- end
- turtle.select(1)
- turnRight(2)
- forward(2)
- turtle.down()
- turnLeft()
- return true
- end
- local function refuel(count)
- if count == nil then count = 1 end
- function fuelUp()
- os.sleep(4)
- turtle.placeDown()
- turtle.refuel()
- end
- if inPit then
- exitPit()
- end
- deposit()
- forward()
- turnRight()
- turtle.select(2)
- turtle.place()
- turtle.select(1)
- turnLeft()
- forward(2)
- down()
- turtle.digDown()
- for i = 1, count do
- fuelUp()
- end
- exitPit()
- forward()
- turnRight()
- turtle.dig()
- turtle.select(3)
- detail = turtle.getItemDetail()
- if detail and detail.name:match(":(.+)") == "redstone_torch" then
- turtle.select(2)
- turtle.transferTo(4)
- turtle.select(3)
- turtle.transferTo(2)
- end
- turtle.select(1)
- turnRight()
- forward()
- turnRight(2)
- return true
- end
- local function digLoopOnce()
- function digCorner()
- forward()
- turtle.digDown()
- turnRight()
- forward()
- end
- turtle.digDown()
- turnLeft()
- digCorner()
- turtle.digDown()
- digCorner()
- turtle.digDown()
- digCorner()
- turtle.digDown()
- digCorner()
- turnRight()
- end
- local function restartFloodGate()
- if not down() then
- turtle.digDown()
- down()
- end
- turtle.dig()
- for i = 3,16 do
- turtle.select(i)
- detail = turtle.getItemDetail()
- if detail and detail.name:match(":(.+)") == "floodGateBlock" then
- turtle.place()
- turtle.select(1)
- break
- end
- end
- up()
- end
- local function start()
- if not inPit then
- enterPit()
- end
- restartFloodGate()
- if loops > 0 then
- remaining = loops
- else
- remaining = -1
- end
- while remaining ~= 0 do
- if turtle.getFuelLevel() < 5000 then
- exitPit()
- refuel(10)
- enterPit()
- end
- digLoopOnce()
- os.sleep(35) -- Wait for pumps to fill floodgate enough for it to fill floor
- restartFloodGate()
- if turtle.getItemCount(16) > 0 then
- exitPit()
- deposit()
- enterPit()
- end
- if remaining > 0 then remaining = remaining - 1 end
- end
- if inPit then
- exitPit()
- end
- end
- start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement