SHOW:
|
|
- or go back to the newest paste.
1 | --API interface for turtles. | |
2 | ||
3 | ||
4 | ||
5 | ----------------- | |
6 | --FUEL COMMANDS-- | |
7 | ----------------- | |
8 | ||
9 | --refil fuel level | |
10 | function refil() | |
11 | if turtle.getFuelLevel() ~= "unlimited" then | |
12 | if turtle.getFuelLevel() <1 then | |
13 | for i=1,16 do | |
14 | turtle.select(i) | |
15 | if turtle.refuel(1) then | |
16 | return true | |
17 | end | |
18 | end | |
19 | print("cT.API_Error::NoFuelFound") | |
20 | print("R_Application Suspended") | |
21 | print("S_Add Fuel And Press <Any Key>") | |
22 | os.pullEvent("key") | |
23 | return false | |
24 | else | |
25 | return true | |
26 | end | |
27 | end | |
28 | end | |
29 | ||
30 | ||
31 | ||
32 | -------------------- | |
33 | --TURNING COMMANDS-- | |
34 | -------------------- | |
35 | ||
36 | --Turning Left Command | |
37 | function tL(qty) | |
38 | if qty == nil then | |
39 | qty = 1 | |
40 | end | |
41 | turtle.turnLeft() | |
42 | qty = qty -1 | |
43 | if qty > 0 then | |
44 | tL(qty) | |
45 | end | |
46 | return true | |
47 | end | |
48 | ||
49 | --Turning Right Command | |
50 | function tR(qty) | |
51 | if qty == nil then | |
52 | qty = 1 | |
53 | end | |
54 | turtle.turnRight() | |
55 | qty = qty -1 | |
56 | if qty > 0 then | |
57 | tR(qty) | |
58 | end | |
59 | return true | |
60 | end | |
61 | ||
62 | ||
63 | ||
64 | ------------------- | |
65 | --DIGING COMMANDS-- | |
66 | ------------------ | |
67 | ||
68 | --Dig Forwards Command | |
69 | function dF() | |
70 | turtle.dig() | |
71 | end | |
72 | ||
73 | --Dig UpwardsCommand | |
74 | function dU() | |
75 | turtle.digUp() | |
76 | end | |
77 | ||
78 | --Dig Forwards Command | |
79 | function dD() | |
80 | turtle.digDown() | |
81 | end | |
82 | ||
83 | --Dig Left Command | |
84 | function dL() | |
85 | tL(1) | |
86 | dF() | |
87 | tR(1) | |
88 | end | |
89 | ||
90 | --Dig Right Command | |
91 | function dR() | |
92 | tR(1) | |
93 | dF() | |
94 | tL(1) | |
95 | end | |
96 | ||
97 | --Dig Backwards Command | |
98 | function dB() | |
99 | tL(2) | |
100 | dF() | |
101 | tL(2) | |
102 | end | |
103 | ||
104 | ||
105 | ||
106 | --------------------- | |
107 | --MOVEMENT COMMANDS-- | |
108 | --------------------- | |
109 | ||
110 | --Move Forward command | |
111 | function mF(blocks) | |
112 | if blocks == nil then | |
113 | blocks = 1 | |
114 | end | |
115 | refil() | |
116 | if turtle.forward() then | |
117 | blocks = blocks - 1 | |
118 | else | |
119 | dF() | |
120 | end | |
121 | if blocks > 0 then | |
122 | mF(blocks) | |
123 | end | |
124 | return true | |
125 | end | |
126 | ||
127 | --Move Backward command | |
128 | function mB(blocks) | |
129 | if blocks == nil then | |
130 | blocks = 1 | |
131 | end | |
132 | refil() | |
133 | if turtle.back() then | |
134 | blocks = blocks - 1 | |
135 | else | |
136 | dB() | |
137 | end | |
138 | if blocks > 0 then | |
139 | mB(blocks) | |
140 | end | |
141 | return true | |
142 | end | |
143 | ||
144 | --Move Left command | |
145 | function mL(blocks) | |
146 | if blocks == nil then | |
147 | blocks = 1 | |
148 | end | |
149 | refil() | |
150 | tL() | |
151 | if turtle.forward() then | |
152 | blocks = blocks - 1 | |
153 | else | |
154 | dL() | |
155 | end | |
156 | if blocks > 0 then | |
157 | mL(blocks) | |
158 | end | |
159 | return true | |
160 | end | |
161 | ||
162 | --Move Right command | |
163 | function mR(blocks) | |
164 | if blocks == nil then | |
165 | blocks = 1 | |
166 | end | |
167 | refil() | |
168 | tR() | |
169 | if turtle.forward() then | |
170 | blocks = blocks - 1 | |
171 | else | |
172 | dR() | |
173 | end | |
174 | if blocks > 0 then | |
175 | mR(blocks) | |
176 | end | |
177 | return true | |
178 | end | |
179 | ||
180 | --Move Up command | |
181 | function mU(blocks) | |
182 | if blocks == nil then | |
183 | blocks = 1 | |
184 | end | |
185 | refil() | |
186 | if turtle.up() then | |
187 | blocks = blocks - 1 | |
188 | else | |
189 | dU() | |
190 | end | |
191 | if blocks > 0 then | |
192 | mU(blocks) | |
193 | end | |
194 | return true | |
195 | end | |
196 | ||
197 | --Move Down command | |
198 | function mD(blocks) | |
199 | if blocks == nil then | |
200 | blocks = 1 | |
201 | end | |
202 | refil() | |
203 | if turtle.down() then | |
204 | blocks = blocks - 1 | |
205 | else | |
206 | dD() | |
207 | end | |
208 | if blocks > 0 then | |
209 | mD(blocks) | |
210 | end | |
211 | return true | |
212 | end |