Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vos.loadAPI('core.api')
- vos.loadAPI('tl2.api')
- TL2.setStatus = function(status)
- turtle.status = status
- end
- local function place(action)
- while true do
- local slot = TL2.selectSlotWithItems()
- if not slot then
- return false
- end
- if action.place() then
- return true
- end
- if action.detect() then
- return true
- end
- turtle.drop(1)
- end
- end
- local function escape()
- TL2.setStatus('escaping')
- local loc = TL2.getLocation('enderChest')
- TL2.gotoZ(loc.z - 5)
- while not TL2.gotoLocation('enderChest') do
- sleep(1)
- end
- for i = 1, 10 do
- if not turtle.detect() then
- TL2.forward()
- end
- end
- end
- local function fillHole()
- TL2.turnAround()
- place(TL2.actions.forward)
- TL2.turnAround()
- end
- local function fill()
- TL2.setStatus('filling')
- while true do
- if TL2.getState().abort or
- (turtle.getFuelLevel() < 500) then
- break
- end
- while not turtle.detect() do
- TL2.forward()
- while not turtle.detectDown() do
- TL2.down()
- end
- end
- TL2.turnLeft()
- while not turtle.detect() do
- TL2.forward()
- while not turtle.detectDown() do
- TL2.down()
- end
- end
- TL2.turnRight()
- if turtle.detect() then
- TL2.turnLeft()
- while TL2.back() do
- if not place(TL2.actions.forward) then
- return
- end
- while not turtle.detectDown() do
- TL2.down()
- end
- end
- TL2.turnRight()
- if not TL2.back() then
- TL2.turnLeft()
- if turtle.detect() then
- TL2.up()
- if not place(TL2.actions.down) then
- return
- end
- for i = 1, 4 do
- if not turtle.detect() then
- break
- end
- TL2.turnLeft()
- end
- if turtle.detect() then
- local ctr = 0
- while turtle.detectUp() do
- ctr = ctr + 1
- if ctr > 10 then
- return
- end
- TL2.forward()
- fillHole()
- if not turtle.detect() then break end
- TL2.turnLeft()
- if not turtle.detect() then break end
- TL2.forward()
- fillHole()
- if not turtle.detect() then break end
- TL2.turnRight()
- if not turtle.detect() then break end
- end
- end
- end
- elseif not place(TL2.actions.forward) then
- return
- end
- end
- if (TL2.getState().pt.z > -1) then
- break
- end
- end
- end
- function refill()
- TL2.setStatus('refilling')
- local loc = TL2.getLocation('enderChest')
- if TL2.getState().pt.z < 0 then
- TL2.gotoZ(loc.z - 5)
- end
- while not TL2.gotoLocation('enderChest') do
- sleep(1)
- end
- if Peripheral.isPresent({ type = 'ender_chest' }) then
- turtle.select(1)
- for i = 1, 16 do
- turtle.suckUp()
- end
- TL2.forward()
- return true
- end
- end
- TL2.setPolicy(TL2.policies.digAttack)
- TL2.setDigPolicy(TL2.digPolicy.turtleSafe)
- TL2.saveLocation('enderChest')
- print('model 501a')
- sleep(3)
- if refill() then
- while true do
- fill()
- if TL2.getState().abort or
- turtle.getFuelLevel() < 500 or
- TL2.getState().pt.z > -1 then
- escape()
- break
- end
- if not refill() then
- escape()
- break
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement