SHOW:
|
|
- or go back to the newest paste.
1 | --Place chest to hold your enchanted items in front of turtle. | |
2 | --Place chest to hold unenchanted books above turtle | |
3 | ||
4 | m=peripheral.wrap("right") | |
5 | m.setAutoCollect(true) | |
6 | local level = 0 | |
7 | ||
8 | function checkLevel() | |
9 | level = m.getLevels() | |
10 | print("Current level: "..level) | |
11 | return level | |
12 | end | |
13 | ||
14 | function enchantBook() | |
15 | print("Enchanting...") | |
16 | turtle.select(2) | |
17 | m.enchant(30) | |
18 | turtle.down() | |
19 | turtle.drop() | |
20 | turtle.up() | |
21 | end | |
22 | ||
23 | function checkBook() | |
24 | turtle.select(1) | |
25 | if turtle.getItemCount(2) > 1 then | |
26 | turtle.select(2) | |
27 | turtle.drop() | |
28 | elseif turtle.getItemCount(2) == 0 then | |
29 | if turtle.getItemCount(1) == 0 then | |
30 | turtle.suckUp() | |
31 | if turtle.getItemCount(1) == 0 then | |
32 | print("Out of books.") | |
33 | else | |
34 | turtle.transferTo(2,1) | |
35 | enchantBook() | |
36 | end | |
37 | else | |
38 | turtle.transferTo(2, 1) | |
39 | enchantBook() | |
40 | end | |
41 | else | |
42 | enchantBook() | |
43 | end | |
44 | end | |
45 | ||
46 | --main program | |
47 | print("I am an Enchanting Turtle.") | |
48 | while true do | |
49 | if checkLevel() >= 30 then | |
50 | checkBook() | |
51 | end | |
52 | sleep (10) | |
53 | end |