Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor = peripheral.wrap("right")
- local blockName = "minecraft:coarse_dirt"
- function getCoarseDirtAmount()
- local total = 0
- for slot = 1, 16 do
- local item = turtle.getItemDetail(slot)
- if item and item.name == blockName then
- total = total + item.count
- end
- end
- return total
- end
- function doDig()
- for i = 2, 15 do
- local item = turtle.getItemDetail(i)
- if item and item.name == blockName then
- turtle.select(i)
- turtle.place()
- turtle.dig()
- turtle.select(16)
- turtle.equipRight()
- turtle.dig()
- turtle.equipRight()
- return true
- end
- end
- return false
- end
- -- Initialize
- local total = getCoarseDirtAmount()
- local progress = 0
- local dropBuffer = 0
- local DROP_EVERY = 5 -- Drop after every 5 tilled blocks
- -- Main loop
- while doDig() do
- progress = progress + 1
- dropBuffer = dropBuffer + 1
- -- Display update
- monitor.clear()
- monitor.setCursorPos(1, 1)
- monitor.setTextColor(colors.lime)
- monitor.write("TILLER_d")
- monitor.setCursorPos(1, 2)
- monitor.setTextColor(colors.white)
- monitor.write("At")
- monitor.setCursorPos(1, 3)
- monitor.write(progress .. "/" .. total)
- -- Drop when buffer reaches threshold
- if dropBuffer >= DROP_EVERY then
- turtle.select(1)
- turtle.dropUp()
- dropBuffer = 0
- end
- end
- -- Final drop (in case leftovers weren't dumped)
- if dropBuffer > 0 then
- turtle.select(1)
- turtle.dropUp()
- end
- -- Done message
- monitor.clear()
- monitor.setCursorPos(1, 1)
- monitor.setTextColor(colors.lime)
- monitor.write("--------")
- monitor.setCursorPos(1, 2)
- monitor.write("Tilling")
- monitor.setCursorPos(1, 3)
- monitor.write("complete")
Advertisement
Add Comment
Please, Sign In to add comment