Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ench = peripheral.wrap("right")
- ench.setAutoCollect(true)
- level = 0
- function clear_inventory()
- for i = 2,15 do
- turtle.select(i)
- turtle.dropUp()
- end
- end
- function enchant(ench)
- turtle.select(1)
- ench.collect()
- state = not redstone.getOutput("bottom")
- if not turtle.compareTo(16) then
- turtle.dropUp()
- end
- if turtle.getItemCount(1) == 0 then
- print("Out of books; taking from book chest.")
- while not turtle.suckDown() do
- print("No books in book chest. Sleeping for 1 minute.")
- sleep(60)
- end
- end
- -- if we've gotten this far, we have some books in slot 1.
- print("Enchanting levels: " .. ench.getLevels() .. "\n")
- while ench.getLevels() >= 30 do
- turtle.select(1)
- if turtle.getItemCount(1) > 1 then
- turtle.transferTo(2, 1)
- turtle.select(2)
- end
- ench.enchant(30)
- while not turtle.dropUp() do
- print("Output chest full. Sleeping for 1 minute.")
- sleep(60)
- end
- turtle.select(1)
- end
- end
- function attack()
- for i=1,10 do
- turtle.attack()
- sleep(0.1)
- end
- end
- while true do
- if (level ~= ench.getLevels()) then
- level = ench.getLevels()
- if ((level <= 25 and level % 5 == 0) or level > 25) then
- print("Turtle at level: " .. level)
- end
- end
- if (ench.getLevels() >= 30) then
- clear_inventory()
- enchant(ench)
- end
- turtle.attack()
- --attack() -- attack for one second.
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement