Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- cap - caps a square hole
- -- Designed for covering the holes from a quarry
- -- Place on the bottom level you want to cap in a corner.
- local drop_slots = { 1, 15 }
- local fuel_slot = 16
- local refuel_level = 0
- function getEmptySlots()
- numslots = 0
- for i = drop_slots[1], drop_slots[2] do
- if turtle.getItemCount(i) == 0 then
- numslots = numslots + 1
- end
- end
- return numslots
- end
- function isDropSlotsEmpty()
- return getEmptySlots() == drop_slots[2] - drop_slots[1]
- end
- function refuel()
- while turtle.getFuelLevel() == 0 do
- if turtle.getItemCount(fuel_slot) ~= 0 then
- turtle.select(fuel_slot)
- turtle.refuel(1)
- else
- sleep(1)
- end
- end
- turtle.select(drop_slots[1])
- end
- function cap(levels)
- for i = 1,levels do
- local count
- turtle.turnLeft()
- count = turtle.detect() and 0 or 1
- turtle.turnRight()
- refuel()
- turtle.up()
- while true do
- if (turtle.detect() or turtle.detectDown()) then break end
- while not turtle.detect() and not turtle.detectDown() do
- while isDropSlotsEmpty() do sleep(1000) end
- turtle.placeDown()
- turtle.attack()
- refuel()
- turtle.forward()
- end
- if (turtle.detectDown()) then
- refuel()
- turtle.back()
- else
- while isDropSlotsEmpty() do sleep(1000) end
- turtle.placeDown()
- end
- if (count%2 == 0) then turtle.turnRight() else turtle.turnLeft() end
- if (turtle.detect()) then break end
- turtle.attack()
- refuel()
- turtle.forward()
- if (count%2 == 0) then turtle.turnRight() else turtle.turnLeft() end
- count = count + 1
- end
- end
- end
- local tArgs = { ... }
- if #tArgs == 1 then
- cap(tonumber(tArgs[1]))
- else
- print("usage: cap levels")
- return
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement