SHOW:
|
|
- or go back to the newest paste.
1 | -- Wheat farming turtle by Razputin | |
2 | -- Modified and bugfixed by Pugnacious | |
3 | -- Optimized and cleaned up by Kreezxil 10/6/2013 | |
4 | ||
5 | --[Code for the turtle to leave start position and go to farming level]-- | |
6 | - | turtle.forward() |
6 | + | |
7 | - | turtle.down() |
7 | + | turtle.forward() |
8 | - | turtle.down() |
8 | + | turtle.down() |
9 | turtle.down() | |
10 | end | |
11 | - | --added this function (it was missing) - Pugnacious |
11 | + | |
12 | - | function m() |
12 | + | -- rewrote this function to be extensible and to eliminate the m7 |
13 | - | turtle.forward() |
13 | + | function move(i) |
14 | for j=1,i do | |
15 | turtle.forward() | |
16 | - | --[Multiple move commands]-- |
16 | + | end |
17 | - | function m7() |
17 | + | |
18 | - | m() |
18 | + | |
19 | - | m() |
19 | + | |
20 | - | m() |
20 | + | function down() |
21 | - | m() |
21 | + | turtle.down() |
22 | - | m() |
22 | + | |
23 | - | m() |
23 | + | |
24 | - | m() |
24 | + | |
25 | function returnTurtle() | |
26 | move(7) | |
27 | turtle.up() | |
28 | - | function d() |
28 | + | |
29 | - | turtle.down() |
29 | + | |
30 | --[Planting code]-- | |
31 | function plant() | |
32 | turtle.digDown() | |
33 | - | function re() |
33 | + | turtle.placeDown() |
34 | - | m7() |
34 | + | |
35 | ||
36 | --[Code for returning turn depending on the 'tray' you end on. Odd/even]-- | |
37 | function returningLeftTurn() | |
38 | turtle.turnLeft() | |
39 | - | function p() |
39 | + | turtle.up() |
40 | - | turtle.digDown() |
40 | + | turtle.up() |
41 | - | turtle.placeDown() |
41 | + | |
42 | ||
43 | --[Ditto]-- | |
44 | function returningRightTurn() | |
45 | - | function rlt() |
45 | + | turtle.turnRight() |
46 | - | turtle.turnLeft() |
46 | + | turtle.up() |
47 | turtle.up() | |
48 | end | |
49 | ||
50 | --[For turning at the end of each row of plots. Odd/even]-- | |
51 | function leftTurn() | |
52 | - | function rrt() |
52 | + | turtle.turnLeft() |
53 | turtle.forward() | |
54 | turtle.turnLeft() | |
55 | end | |
56 | ||
57 | --[Ditto]-- | |
58 | function rightTurn() | |
59 | - | function lt() |
59 | + | turtle.turnRight() |
60 | - | turtle.turnLeft() |
60 | + | turtle.forward() |
61 | - | turtle.forward() |
61 | + | turtle.turnRight() |
62 | - | turtle.turnLeft() |
62 | + | |
63 | ||
64 | --[Function for each row of plots]-- | |
65 | function row() | |
66 | - | function rt() |
66 | + | for i=1,5 do |
67 | plant() | |
68 | - | turtle.forward() |
68 | + | move() |
69 | end | |
70 | plant() | |
71 | end | |
72 | ||
73 | ||
74 | - | p() |
74 | + | --['Tray' -the body.]-- |
75 | - | m() |
75 | + | -- by kreezxil to make trayOdd() and trayEven() more readable |
76 | - | p() |
76 | + | |
77 | - | m() |
77 | + | function trayBody() |
78 | - | p() |
78 | + | turtle.refuel() |
79 | - | m() |
79 | + | |
80 | - | p() |
80 | + | for i=1,3 do |
81 | - | m() |
81 | + | row() |
82 | - | p() |
82 | + | rightTurn() |
83 | - | m() |
83 | + | row() |
84 | - | p() |
84 | + | leftTurn() |
85 | end | |
86 | ||
87 | end | |
88 | ||
89 | --['Tray' odd.]-- | |
90 | - | function to() |
90 | + | |
91 | ||
92 | - | row() |
92 | + | function trayOdd() |
93 | - | rt() |
93 | + | trayBody() |
94 | - | row() |
94 | + | row() |
95 | - | lt() |
95 | + | rightTurn() |
96 | - | row() |
96 | + | down() |
97 | - | rt() |
97 | + | |
98 | - | row() |
98 | + | |
99 | - | lt() |
99 | + | |
100 | - | row() |
100 | + | |
101 | - | rt() |
101 | + | |
102 | - | row() |
102 | + | function trayEven() |
103 | - | lt() |
103 | + | trayBody() |
104 | - | row() |
104 | + | row() |
105 | - | rt() |
105 | + | leftTurn() |
106 | - | d() |
106 | + | down() |
107 | end | |
108 | ||
109 | --[Start of the executable part of program]-- | |
110 | -- Added refuel and set the order of inventory selections. | |
111 | -- Inventory box 1 is for fuel and the rest is for seeds. | |
112 | - | function te() |
112 | + | |
113 | turtle.refuel() | |
114 | - | row() |
114 | + | |
115 | - | lt() |
115 | + | |
116 | - | row() |
116 | + | trayOdd() |
117 | - | rt() |
117 | + | |
118 | - | row() |
118 | + | trayEven() |
119 | - | lt() |
119 | + | |
120 | - | row() |
120 | + | trayOdd() |
121 | - | rt() |
121 | + | |
122 | - | row() |
122 | + | trayEven() |
123 | - | lt() |
123 | + | returningLeftTurn() |
124 | - | row() |
124 | + | returnTurtle() |
125 | - | rt() |
125 | + | returnTurtle() |
126 | - | row() |
126 | + | returnTurtle() |
127 | - | lt() |
127 | + | move(7) |
128 | - | d() |
128 | + | |
129 | turtle.back() | |
130 | turtle.up() | |
131 | turtle.up() | |
132 | turtle.back() |