SHOW:
|
|
- or go back to the newest paste.
1 | local version = | |
2 | 5.0 | |
3 | -- Pri zmene programu je treba na radku 2 zmenit verzi, aby se program automaticky aktualizoval | |
4 | -- local code je treba zmenit dle potreby | |
5 | ||
6 | --Vize - plán: | |
7 | -- Těžba na více stran | |
8 | -- Pokládání anchorů a vkládání Ender pearl pro delší těžbu | |
9 | -- Využití všech slotů turtly a pokládání méně často Ender Chestky / méně často vyprazdňovat | |
10 | -- Enderchestku na druhé straně vyprazdňovat rychleji | |
11 | ||
12 | - | local code = "bxrSpssk" |
12 | + | ------------------------------------------------------------------------------------------------ |
13 | --TEST UPDATE | |
14 | ------------------------------------------------------------------------------------------------ | |
15 | local code = "3WrsQeNq" | |
16 | ||
17 | --check version | |
18 | term.clear() | |
19 | term.setCursorPos(1,1) | |
20 | print("Program loading...") | |
21 | print("Current version: "..version) | |
22 | local updateSite= http.get("http://pastebin.com/raw.php?i="..code) | |
23 | updateSite.readLine() | |
24 | local newVersion = updateSite.readLine() | |
25 | if tonumber(newVersion) > version then | |
26 | print("Update required. Updating now...") | |
27 | local updateSite = http.get("http://pastebin.com/raw.php?i="..code) | |
28 | local siteFile = updateSite.readAll() | |
29 | local writeFile = fs.open(shell.getRunningProgram(),"w") | |
30 | writeFile.write(siteFile) | |
31 | writeFile.close() | |
32 | print("The program will now restart your computer.") | |
33 | sleep(1) | |
34 | os.reboot() | |
35 | - | -- start hlavního programu |
35 | + | |
36 | ||
37 | - | -- nastavíme hloubku kopani |
37 | + | ------------------------------------------------------------------------------------------------ |
38 | - | local hlb = 50 |
38 | + | --START |
39 | ------------------------------------------------------------------------------------------------ | |
40 | - | while true do |
40 | + | |
41 | function start() | |
42 | - | -- cyklus pro kopani xxx dolu |
42 | + | -- start hlavního programu |
43 | - | -- turtla bude kopat dolů a posílat itemy do EnderChest |
43 | + | |
44 | -- nastavíme hloubku kopani | |
45 | - | -- před startem je třeba provést ošetření/kontrolu, zda turtla nemá nad sebou Ender Chest, pokud ano, vcucni ji a dej do slotu 3 |
45 | + | local hlb = 50 |
46 | - | -- kontrola je nutná kvůli odhlášení, či restartu serveru |
46 | + | local delka = 50 |
47 | ||
48 | - | turtle.select(3) |
48 | + | while true do |
49 | - | local success, data = turtle.inspectUp() |
49 | + | |
50 | -- cyklus pro kopani dolu | |
51 | - | if success then |
51 | + | -- turtla bude kopat dolů a posílat itemy do EnderChest |
52 | - | print("Block name: ", data.name) |
52 | + | |
53 | - | dataEnder = data.name |
53 | + | |
54 | - | print("Block metadata: ", data.metadata) |
54 | + | |
55 | - | if dataEnder == "EnderStorage:enderChest" then |
55 | + | ------------------------------------------------------------------------------------------------ |
56 | - | print("Nalezena Ender Chest") |
56 | + | --TEST ENDER CHEST UP |
57 | - | turtle.digUp() |
57 | + | -- před startem je třeba provést ošetření/kontrolu, zda turtla nemá nad sebou Ender Chest (ECH) |
58 | -- pokud ano, vcucni ji a dej do slotu 16 (ošetřit aby byl slot 16 volný) | |
59 | -- kontrola ECH je nutná kvůli odhlášení, či restartu serveru | |
60 | ------------------------------------------------------------------------------------------------ | |
61 | - | --provedeme prvotni refuel, aby Turtla mohla dělat posun |
61 | + | |
62 | - | turtle.select(1) |
62 | + | turtle.select(16) |
63 | - | turtle.refuel() |
63 | + | local success, data = turtle.inspectUp() |
64 | - | print("Proveden refuel...") |
64 | + | |
65 | if success then | |
66 | print("Block name: ", data.name) | |
67 | - | for a=1,hlb,1 do |
67 | + | dataEnder = data.name |
68 | - | turtle.select(1) |
68 | + | print("Block metadata: ", data.metadata) |
69 | - | turtle.digDown() |
69 | + | if dataEnder == "EnderStorage:enderChest" then |
70 | - | turtle.select(2) |
70 | + | print("Nalezena Ender Chest") |
71 | - | turtle.dig() |
71 | + | turtle.digUp() |
72 | - | turtle.down() |
72 | + | end |
73 | end | |
74 | - | --provedeme kontrolu, zda neni natezen Coal v sl. 1,2 |
74 | + | |
75 | - | --pokud je natezen Coal, proved Refuel |
75 | + | ------------------------------------------------------------------------------------------------ |
76 | - | local data1 = turtle.getItemDetail() |
76 | + | --REFUEL |
77 | ------------------------------------------------------------------------------------------------ | |
78 | - | if data1 then |
78 | + | |
79 | - | print("Item name: ", data1.name) |
79 | + | --provedeme prvotni refuel, aby Turtla mohla dělat posun |
80 | - | dataX1 = data1.name |
80 | + | turtle.select(15) |
81 | - | if dataX1 == "minecraft:coal" then |
81 | + | turtle.refuel() |
82 | - | print("Nalezen coal. Provedu refuel.") |
82 | + | print("Proveden refuel...") |
83 | - | turtle.refuel() |
83 | + | |
84 | ||
85 | - | print("Item damage value: ", data1.damage) |
85 | + | for a=1,delka,1 do |
86 | - | print("Item count: ", data1.count) |
86 | + | |
87 | turtle.select(1) | |
88 | turtle.dig() | |
89 | - | local data2 = turtle.getItemDetail() |
89 | + | turtle.select(2) |
90 | - | turtle.select(2) |
90 | + | turtle.digDown() |
91 | - | if data2 then |
91 | + | turtle.select(3) |
92 | - | print("Item name: ", data2.name) |
92 | + | turtle.digUp() --ošetřit gravel a sand |
93 | - | dataX2 = data2.name |
93 | + | |
94 | - | if dataX2 == "minecraft:coal" then |
94 | + | |
95 | - | print("Nalezen coal. Provedu refuel.") |
95 | + | --provedeme kontrolu, zda neni natezen Coal v sl. 1,2.3 |
96 | - | turtle.refuel() |
96 | + | --pokud je natezen Coal, proved Refuel |
97 | ||
98 | - | print("Item damage value: ", data2.damage) |
98 | + | local data1 = turtle.getItemDetail() |
99 | - | print("Item count: ", data2.count) |
99 | + | if data1 then |
100 | print("Item name: ", data1.name) | |
101 | - | turtle.select(3) |
101 | + | dataX1 = data1.name |
102 | - | -- Enderchest musi byt umistena ve slotu 3 |
102 | + | if dataX1 == "minecraft:coal" then |
103 | - | --poloz Ender Chest a Slot 1,2 vyprazdni do Ender Chest |
103 | + | print("Nalezen coal. Provedu refuel.") |
104 | - | turtle.placeUp() |
104 | + | turtle.refuel() |
105 | - | turtle.select(1) |
105 | + | end |
106 | - | turtle.dropUp() |
106 | + | print("Item damage value: ", data1.damage) |
107 | - | turtle.select(2) |
107 | + | print("Item count: ", data1.count) |
108 | - | turtle.dropUp() |
108 | + | end |
109 | - | --vrat Ender Chest do slotu 3 |
109 | + | |
110 | - | turtle.select(3) |
110 | + | local data2 = turtle.getItemDetail() |
111 | - | turtle.digUp() |
111 | + | turtle.select(2) |
112 | - | a=a+1 |
112 | + | if data2 then |
113 | - | print(a) |
113 | + | print("Item name: ", data2.name) |
114 | dataX2 = data2.name | |
115 | if dataX2 == "minecraft:coal" then | |
116 | - | turtle.forward() |
116 | + | print("Nalezen coal. Provedu refuel.") |
117 | turtle.refuel() | |
118 | - | --vyjedeme pro jistotu o 5 výše kvuli bedrocku |
118 | + | end |
119 | - | turtle.up() |
119 | + | print("Item damage value: ", data2.damage) |
120 | - | turtle.up() |
120 | + | print("Item count: ", data2.count) |
121 | - | turtle.up() |
121 | + | end |
122 | - | turtle.up() |
122 | + | |
123 | - | turtle.up() |
123 | + | local data3 = turtle.getItemDetail() |
124 | turtle.select(3) | |
125 | - | --otocime Turtlu doprava a dig, a popojedeme dopredu,aby nejela nahoru naprazdno |
125 | + | if data3 then |
126 | - | --turtle.turnRight() |
126 | + | print("Item name: ", data3.name) |
127 | dataX2 = data3.name | |
128 | - | turtle.forward() |
128 | + | if dataX3 == "minecraft:coal" then |
129 | print("Nalezen coal. Provedu refuel.") | |
130 | - | print("Jedu nahoru") |
130 | + | turtle.refuel() |
131 | end | |
132 | - | -- cyklus pro vraceni |
132 | + | print("Item damage value: ", data3.damage) |
133 | - | for a=1,hlb,1 do |
133 | + | print("Item count: ", data3.count) |
134 | - | turtle.select(1) |
134 | + | end |
135 | - | turtle.digUp() |
135 | + | |
136 | - | turtle.select(2) |
136 | + | turtle.select(16) |
137 | - | turtle.dig() |
137 | + | -- Enderchest musi byt umistena ve slotu 16 |
138 | - | |
138 | + | -- poloz Ender Chest a Slot 1,2,3 vyprazdni do Ender Chest |
139 | - | --provedeme kontrolu, zda neni natezen Coal v sl. 1,2 |
139 | + | turtle.placeUp() |
140 | - | --pokud je natezen Coal, proved Refuel |
140 | + | |
141 | turtle.select(1) | |
142 | - | local data1b = turtle.getItemDetail() |
142 | + | turtle.dropUp() |
143 | - | turtle.select(1) |
143 | + | turtle.select(2) |
144 | - | if data1b then |
144 | + | turtle.dropUp() |
145 | - | print("Item name: ", data1b.name) |
145 | + | turtle.select(3) |
146 | - | dataX1b = data1b.name |
146 | + | turtle.dropUp() |
147 | - | if dataX1b == "minecraft:coal" then |
147 | + | |
148 | - | print("Nalezen coal. Provedu refuel.") |
148 | + | --vrat Ender Chest do slotu 16 |
149 | - | turtle.refuel() |
149 | + | turtle.select(16) |
150 | turtle.digUp() | |
151 | - | print("Item damage value: ", data1b.damage) |
151 | + | |
152 | - | print("Item count: ", data1b.count) |
152 | + | -- popojedeme o jedno dopredu |
153 | turtle.forward() | |
154 | ||
155 | - | local data2b = turtle.getItemDetail() |
155 | + | a=a+1 |
156 | - | turtle.select(2) |
156 | + | print(a) |
157 | - | if data2b then |
157 | + | |
158 | - | print("Item name: ", data2b.name) |
158 | + | |
159 | - | dataX2b = data2b.name |
159 | + | -- otoceni a chod zpet |
160 | - | if dataX2b == "minecraft:coal" then |
160 | + | turtle.select(4) |
161 | - | print("Nalezen coal. Provedu refuel.") |
161 | + | turtle.turnLeft() |
162 | - | turtle.refuel() |
162 | + | turtle.turnLeft() |
163 | turtle.Down() | |
164 | - | print("Item damage value: ", data2b.damage) |
164 | + | turtle.digDown() --vypraznit slot 4 take |
165 | - | print("Item count: ", data2b.count) |
165 | + | turtle.Down() |
166 | ||
167 | - | turtle.select(3) |
167 | + | |
168 | - | -- Enderchest musi byt umistena ve slotu 3 |
168 | + | |
169 | - | --poloz Ender Chest a Slot 1,2 vyprazdni do Ender Chest |
169 | + | |
170 | - | turtle.placeUp() |
170 | + | print("Jedu zpet") |
171 | - | turtle.select(1) |
171 | + | ------------------------------------------------------------------------ |
172 | - | turtle.dropUp() |
172 | + | for a=1,delka,1 do |
173 | - | turtle.select(2) |
173 | + | |
174 | - | turtle.dropUp() |
174 | + | turtle.select(1) |
175 | - | --vrat Ender Chest do slotu 3 |
175 | + | turtle.dig() |
176 | - | turtle.select(3) |
176 | + | turtle.select(2) |
177 | - | turtle.digUp() |
177 | + | turtle.digDown() |
178 | - | turtle.up() |
178 | + | turtle.select(3) |
179 | - | a=a+1 |
179 | + | turtle.digUp() --ošetřit gravel a sand |
180 | - | print(a) |
180 | + | |
181 | ||
182 | --provedeme kontrolu, zda neni natezen Coal v sl. 1,2.3 | |
183 | - | --opakujeme tezbu v dalsim sloupci |
183 | + | --pokud je natezen Coal, proved Refuel |
184 | ||
185 | - | turtle.forward() |
185 | + | local data1 = turtle.getItemDetail() |
186 | if data1 then | |
187 | - | turtle.forward() |
187 | + | print("Item name: ", data1.name) |
188 | dataX1 = data1.name | |
189 | if dataX1 == "minecraft:coal" then | |
190 | - | -- konec hlavního programu |
190 | + | print("Nalezen coal. Provedu refuel.") |
191 | turtle.refuel() | |
192 | end | |
193 | print("Item damage value: ", data1.damage) | |
194 | print("Item count: ", data1.count) | |
195 | end | |
196 | ||
197 | local data2 = turtle.getItemDetail() | |
198 | turtle.select(2) | |
199 | if data2 then | |
200 | print("Item name: ", data2.name) | |
201 | dataX2 = data2.name | |
202 | if dataX2 == "minecraft:coal" then | |
203 | print("Nalezen coal. Provedu refuel.") | |
204 | turtle.refuel() | |
205 | end | |
206 | print("Item damage value: ", data2.damage) | |
207 | print("Item count: ", data2.count) | |
208 | end | |
209 | ||
210 | local data3 = turtle.getItemDetail() | |
211 | turtle.select(3) | |
212 | if data3 then | |
213 | print("Item name: ", data3.name) | |
214 | dataX2 = data3.name | |
215 | if dataX3 == "minecraft:coal" then | |
216 | print("Nalezen coal. Provedu refuel.") | |
217 | turtle.refuel() | |
218 | end | |
219 | print("Item damage value: ", data3.damage) | |
220 | print("Item count: ", data3.count) | |
221 | end | |
222 | ||
223 | turtle.select(16) | |
224 | -- Enderchest musi byt umistena ve slotu 16 | |
225 | -- poloz Ender Chest a Slot 1,2,3 vyprazdni do Ender Chest | |
226 | turtle.placeUp() | |
227 | ||
228 | turtle.select(1) | |
229 | turtle.dropUp() | |
230 | turtle.select(2) | |
231 | turtle.dropUp() | |
232 | turtle.select(3) | |
233 | turtle.dropUp() | |
234 | ||
235 | --vrat Ender Chest do slotu 16 | |
236 | turtle.select(16) | |
237 | turtle.digUp() | |
238 | ||
239 | -- popojedeme o jedno dopredu | |
240 | turtle.forward() | |
241 | ||
242 | a=a+1 | |
243 | print(a) | |
244 | end | |
245 | ----------------------------------------------------------------------------------------- | |
246 | -- otoceni a chod zpet | |
247 | turtle.select(4) | |
248 | turtle.turnLeft() | |
249 | turtle.turnLeft() | |
250 | turtle.Down() | |
251 | turtle.digDown() --vypraznit slot 4 take | |
252 | turtle.Down() | |
253 | ||
254 | ||
255 | -- konec hlavního programu | |
256 | end | |
257 | end | |
258 | ------------------------------------------------------------------------------------------------ | |
259 | --END | |
260 | ------------------------------------------------------------------------------------------------ | |
261 | ||
262 | ||
263 | start() |