SHOW:
|
|
- or go back to the newest paste.
| 1 | - | local lastState = false |
| 1 | + | local xpApi = peripheral.wrap("right")
|
| 2 | - | local dropInterval = 0 |
| 2 | + | local collectedXp |
| 3 | ||
| 4 | while 1 do | |
| 5 | - | if redstone.testBundledInput("top", 1) == true then
|
| 5 | + | if redstone.getInput("top") == true then
|
| 6 | - | if lastState == false then |
| 6 | + | collectedXp = xpApi.collect() |
| 7 | - | lastState = true |
| 7 | + | if collectedXp > 0 then |
| 8 | print("Collected " .. collectedXp .. " XP. Current level is " .. xpApi.getLevels())
| |
| 9 | - | if dropInterval >= 1200 then |
| 9 | + | |
| 10 | - | dropInterval = 0 |
| 10 | + | if xpApi.getLevels() >= 30 then |
| 11 | - | for i = 1, 16, 1 do |
| 11 | + | for i = 1, 15, 1 do |
| 12 | - | turtle.select(i) |
| 12 | + | if turtle.getItemCount(i) > 0 then |
| 13 | - | turtle.drop() |
| 13 | + | turtle.select(i) |
| 14 | break | |
| 15 | - | else |
| 15 | + | elseif i == 15 then |
| 16 | - | dropInterval = dropInterval + 1 |
| 16 | + | print("out of books!")
|
| 17 | end | |
| 18 | - | turtle.attack() |
| 18 | + | |
| 19 | - | sleep(0.1) |
| 19 | + | turtle.transferTo(16, 1) |
| 20 | turtle.select(16) | |
| 21 | - | if lastState == true then |
| 21 | + | xpApi.enchant(30) |
| 22 | - | for i = 1, 16, 1 do |
| 22 | + | turtle.drop() |
| 23 | - | turtle.select(i) |
| 23 | + | print("Book enchanted..")
|
| 24 | - | turtle.drop() |
| 24 | + | |
| 25 | sleep(5) | |
| 26 | - | lastState = false |
| 26 | + | |
| 27 | sleep(10) | |
| 28 | end | |
| 29 | end |