Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Constants:
- local maxLevel = 30
- local waitTime = 20
- --Variables:
- local level = 0
- local x = 0
- --Functions:
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function wait()
- for i = 1 , waitTime do
- clear()
- print("Current level = "..m.getLevels()..".")
- print("("..maxLevel-m.getLevels().." more levels until the next enchant.)")
- print("")
- print("Waiting: "..waitTime-x)
- if x >= waitTime then
- x = 1
- else
- x = x + 1
- end
- sleep(1)
- end
- end
- function getLevel()
- level = m.getLevels()
- end
- function collect()
- m.getUp()
- end
- function getBook()
- turtle.select(1)
- turtle.suck()
- if turtle.getItemCount(1) > 1 then
- turtle.drop(turtle.getItemCount(1) -1)
- elseif turtle.getItemCount(1) == 1 then enchant()
- else print("") print("No books...") sleep(2)
- end
- end
- function enchant()
- turtle.select(1)
- m.enchant(maxLevel)
- end
- function deposit()
- turtle.select(1)
- turtle.dropDown()
- end
- --MAIN PROGRAM:
- m = peripheral.wrap("right")
- while true do
- collect()
- level = 0
- getLevel()
- if level >= maxLevel then
- getBook()
- if turtle.getItemCount(1) == 1 then
- enchant()
- deposit()
- end
- end
- wait()
- end
Advertisement
Add Comment
Please, Sign In to add comment