SHOW:
|
|
- or go back to the newest paste.
| 1 | local monitor = peripheral.wrap("right")
| |
| 2 | local blockName = "minecraft:coarse_dirt" | |
| 3 | ||
| 4 | - | local blockName = "minecraft:coarse_dirt" |
| 4 | + | |
| 5 | local total = 0 | |
| 6 | - | |
| 6 | + | for slot = 1, 16 do |
| 7 | - | for slot=1, 16 do |
| 7 | + | |
| 8 | if item and item.name == blockName then | |
| 9 | total = total + item.count | |
| 10 | end | |
| 11 | end | |
| 12 | return total | |
| 13 | - | |
| 13 | + | |
| 14 | ||
| 15 | function doDig() | |
| 16 | for i = 2, 15 do | |
| 17 | local item = turtle.getItemDetail(i) | |
| 18 | - | local foundCoarseDirt = false |
| 18 | + | |
| 19 | - | local slot = 0 |
| 19 | + | turtle.select(i) |
| 20 | - | for i=2, 15 do |
| 20 | + | turtle.place() |
| 21 | - | local b = turtle.getItemDetail(i) |
| 21 | + | turtle.dig() |
| 22 | - | if b and b.name == "minecraft:coarse_dirt" then |
| 22 | + | turtle.select(16) |
| 23 | - | foundCoarseDirt = true |
| 23 | + | turtle.equipRight() |
| 24 | - | slot = i |
| 24 | + | turtle.dig() |
| 25 | - | break |
| 25 | + | turtle.equipRight() |
| 26 | return true | |
| 27 | end | |
| 28 | - | |
| 28 | + | |
| 29 | - | if foundCoarseDirt == false then |
| 29 | + | return false |
| 30 | - | return false |
| 30 | + | |
| 31 | ||
| 32 | - | |
| 32 | + | |
| 33 | - | turtle.select(slot) |
| 33 | + | |
| 34 | - | turtle.place() |
| 34 | + | -- Initialize |
| 35 | - | |
| 35 | + | local total = getCoarseDirtAmount() |
| 36 | - | turtle.dig() |
| 36 | + | local progress = 0 |
| 37 | - | |
| 37 | + | local dropBuffer = 0 |
| 38 | - | turtle.select(16) |
| 38 | + | local DROP_EVERY = 5 -- Drop after every 5 tilled blocks |
| 39 | - | turtle.equipRight() |
| 39 | + | |
| 40 | - | turtle.dig() |
| 40 | + | -- Main loop |
| 41 | - | turtle.equipRight() |
| 41 | + | |
| 42 | - | |
| 42 | + | progress = progress + 1 |
| 43 | dropBuffer = dropBuffer + 1 | |
| 44 | ||
| 45 | - | |
| 45 | + | -- Display update |
| 46 | - | return true |
| 46 | + | |
| 47 | monitor.setCursorPos(1, 1) | |
| 48 | monitor.setTextColor(colors.lime) | |
| 49 | - | local amount = getCoarseDirtAmount() |
| 49 | + | |
| 50 | - | local upToThen = 0 |
| 50 | + | |
| 51 | monitor.setTextColor(colors.white) | |
| 52 | monitor.write("At")
| |
| 53 | - | upToThen = upToThen + 1 |
| 53 | + | |
| 54 | monitor.write(progress .. "/" .. total) | |
| 55 | ||
| 56 | -- Drop when buffer reaches threshold | |
| 57 | if dropBuffer >= DROP_EVERY then | |
| 58 | - | |
| 58 | + | turtle.select(1) |
| 59 | turtle.dropUp() | |
| 60 | dropBuffer = 0 | |
| 61 | end | |
| 62 | end | |
| 63 | - | monitor.write(""..upToThen.."/"..amount)
|
| 63 | + | |
| 64 | -- Final drop (in case leftovers weren't dumped) | |
| 65 | if dropBuffer > 0 then | |
| 66 | turtle.select(1) | |
| 67 | turtle.dropUp() | |
| 68 | end | |
| 69 | ||
| 70 | -- Done message | |
| 71 | monitor.clear() | |
| 72 | monitor.setCursorPos(1, 1) | |
| 73 | monitor.setTextColor(colors.lime) | |
| 74 | - | monitor.setCursorPos(1, 4) |
| 74 | + | |
| 75 | monitor.setCursorPos(1, 2) | |
| 76 | monitor.write("Tilling")
| |
| 77 | monitor.setCursorPos(1, 3) | |
| 78 | monitor.write("complete")
| |
| 79 |