Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Place chest to hold your enchanted items in front of turtle.
- --Place chest to hold unenchanted books above turtle
- m=peripheral.wrap("right")
- m.setAutoCollect(true)
- local level = 0
- function checkLevel()
- level = m.getLevels()
- print("Current level: "..level)
- return level
- end
- function enchantBook()
- print("Enchanting...")
- turtle.select(2)
- m.enchant(30)
- turtle.down()
- turtle.drop()
- turtle.up()
- end
- function checkBook()
- turtle.select(1)
- if turtle.getItemCount(2) > 1 then
- turtle.select(2)
- turtle.drop()
- elseif turtle.getItemCount(2) == 0 then
- if turtle.getItemCount(1) == 0 then
- turtle.suckUp()
- if turtle.getItemCount(1) == 0 then
- print("Out of books.")
- else
- turtle.transferTo(2,1)
- enchantBook()
- end
- else
- turtle.transferTo(2, 1)
- enchantBook()
- end
- else
- enchantBook()
- end
- end
- --main program
- print("I am an Enchanting Turtle.")
- while true do
- if checkLevel() >= 30 then
- checkBook()
- end
- sleep (10)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement