SHOW:
|
|
- or go back to the newest paste.
1 | id=2 | |
2 | id2=163621 | |
3 | ||
4 | rap={wyd="tartak", fun="drwal", nse=2, orp=5, oka=2, zgd=0, stn=0, akt=0, pal=0, pll=turtle.getFuelLevel(), sur=0, gpx=0, gpy=0, gpz=0, pro=0, fnn="", fno="", rod="", nrd=0, var=0, kom=""} | |
5 | ||
6 | ||
7 | ||
8 | program=1 | |
9 | aktywnosc=0 | |
10 | ||
11 | P1={rodzaj="P1", tekst="Czy baza aktywna?"} | |
12 | P2={rodzaj="P2", tekst="Czy pracowac?"} | |
13 | ||
14 | function aktualizuj() | |
15 | napisz("Uruchamiam funkcje aktualizacji.") | |
16 | while true do | |
17 | repeat | |
18 | a5, b5, c5, d5, e5, f5=os.pullEvent("modem_message") | |
19 | until e5.rod=="K" | |
20 | rap.oka=e.oka | |
21 | rap.zgd=e.zgd | |
22 | rap.orp=e.orp | |
23 | sleep(rap.oka) | |
24 | end | |
25 | end | |
26 | ||
27 | ||
28 | function napisz(arg1) | |
29 | local tablica={wyd=rap.wyd, fun=rap.fun, nse=rap.nse, oka=rap.oka, orp=rap.orp, zgd=rap.zgd, stn=rap.stn, akt=rap.akt, pal=rap.pal, pll=rap.pll, sur=rap.sur, gpx=rap.gpx, gpy=rap.gpy, gpz=rap.gpz, pro=rap.pro, rod="F", nrd=0, var=0, kom=arg1, fnn=rap.fnn, fno=rap.fno} --pobiera zmienne z tablicy glownej (wiekszosc) ale przypisuje wlasny rodzaj i tresc komunikatu | |
30 | print(arg1) | |
31 | modem.transmit(1, id, tablica) | |
32 | end | |
33 | ||
34 | function uruchom_modem() | |
35 | ||
36 | modem=peripheral.wrap("right") | |
37 | modem.open(id) | |
38 | if modem.isOpen(id)==true then | |
39 | rap.fnn="W1" | |
40 | rap.fno="uruchom_modem" | |
41 | napisz("Modem otwarty na kanale"..id) | |
42 | else | |
43 | print("Modem nie zostal otwarty") | |
44 | end | |
45 | end | |
46 | ||
47 | function wyslij(arg1) | |
48 | ||
49 | tablica = {numer=id, stan=aktywnosc, rodzaj=arg1.rodzaj, tekst=arg1.tekst} | |
50 | modem.transmit(1, id, tablica) | |
51 | end | |
52 | ||
53 | function raportuj() | |
54 | while true do | |
55 | local tablica={wyd=rap.wyd, fun=rap.fun, nse=rap.nse, orp=rap.orp, oka=rap.oka, zgd=rap.zgd, stn=rap.stn, akt=rap.akt, pal=rap.pal, pll=rap.pll, sur=rap.sur, gpx=rap.gpx, gpy=rap.gpy, gpz=rap.gpz, pro=rap.pro, fnn=rap.fnn, fno=rap.fno, rod=rap.rod, nrd=rap.nrd, var=rap.var, kom=rap.kom} | |
56 | - | modem.transmit(1, id, rap) |
56 | + | |
57 | modem.transmit(1, id, tablica) | |
58 | sleep(rap.orp) | |
59 | end | |
60 | end | |
61 | ||
62 | function odpbazy(q1, q2) | |
63 | os.startTimer(q2) | |
64 | repeat | |
65 | a1, b1, c1, d1, e1, f1 = os.pullEvent() | |
66 | until ((a1=="modem_message") and (q1==e1.rodzaj)) or (a1=="timer") | |
67 | if (a1=="modem_message") and (q1==e1.rodzaj) then | |
68 | return e1.tekst | |
69 | elseif a1=="timer" then | |
70 | return a1 | |
71 | end | |
72 | end | |
73 | ||
74 | function polaczenie_z_baza(arg1, arg2, arg3, arg4) | |
75 | rap.fnn="W2" | |
76 | rap.fno="polaczenie_z_baza" | |
77 | local warunek=0 | |
78 | local licz=0 | |
79 | napisz("Polaczenie_z_baza(): Wysylam pytanie numer:") | |
80 | napisz(arg1) | |
81 | repeat | |
82 | local tablica={wyd=rap.wyd, fun=rap.fun, orp=rap.orp, zgd=rap.zgd, stn=rap.stn, akt=rap.akt, pal=rap.pal, pll=rap.pll, sur=rap.sur, gpx=rap.gpx, gpy=rap.gpy, gpz=rap.gpz, pro=rap.pro, rod="P", nrd=arg1, kom=arg2, var=id2, fnn=rap.fnn, fno=rap.fno} | |
83 | modem.transmit(1, id, tablica) | |
84 | napisz("Polaczenie_z_baza(): proba: "..licz) | |
85 | os.startTimer(arg3) | |
86 | repeat | |
87 | a1, b1, c1, d1, e1, f1 = os.pullEvent() | |
88 | if ((a1=="modem_message") and (e1.nrd==1) and (e1.rod=="P") and (e1.var==id2)) then | |
89 | warunek=1 | |
90 | else | |
91 | warunek=0 | |
92 | end | |
93 | until (warunek==1) or (a1=="timer") | |
94 | licz=licz+1 | |
95 | until (warunek==1) or (licz==arg4) | |
96 | if warunek==1 then | |
97 | napisz("Otrzymalem wiadomosc zwrotna!") | |
98 | return e1.kom | |
99 | elseif a1=="timer" then | |
100 | napisz("polaczenie_z_baza: Uplynal czas oczekiwania.") | |
101 | return a1 | |
102 | else | |
103 | napisz("Nieznany wynik funkcji.") | |
104 | end | |
105 | end | |
106 | ||
107 | function sluchaj(arg1, arg2) | |
108 | local odp=odpbazy(arg1.rodzaj, arg2) | |
109 | return odp | |
110 | end | |
111 | ||
112 | function czypracowac() | |
113 | local odp=sluchaj(P2, 10) | |
114 | if odp=="TAK" then | |
115 | print("Mozna pracowac!") | |
116 | return odp | |
117 | elseif odp=="NIE" then | |
118 | print("Koniec pracy") | |
119 | return odp | |
120 | else | |
121 | print("Inny komunikat") | |
122 | end | |
123 | end | |
124 | ||
125 | function sygnal(kierunek) | |
126 | if kierunek=="przod" then | |
127 | czyjest, blok=turtle.inspect() | |
128 | elseif kierunek=="gora" then | |
129 | czyjest, blok=turtle.inspectUp() | |
130 | elseif kierunek=="dol" then | |
131 | czyjest, blok=turtle.inspectDown() | |
132 | else | |
133 | print("funkcja sygnal ze zlym parametrem") | |
134 | ||
135 | program=0 | |
136 | end | |
137 | ||
138 | if czyjest==false then | |
139 | znaleziono="nic" | |
140 | elseif blok["name"]=="minecraft:log" then | |
141 | znaleziono="drewno" | |
142 | elseif blok["name"]=="minecraft:sapling" then | |
143 | znaleziono="sadzonka" | |
144 | elseif blok["name"]=="minecraft:glass" then | |
145 | znaleziono="szklo" | |
146 | elseif blok["name"]=="minecraft:chest" then | |
147 | znaleziono="skrzynia" | |
148 | elseif blok["name"]=="minecraft:leaves" then | |
149 | znaleziono="lisc" | |
150 | elseif blok["name"]=="minecraft:snow_layer" then | |
151 | znaleziono="snieg" | |
152 | elseif blok["name"]=="minecraft:nether_brick" then | |
153 | znaleziono="ceglanetheru" | |
154 | elseif blok["name"]=="minecraft:stone" then | |
155 | znaleziono="kamien" | |
156 | elseif blok["name"]=="minecraft:lit_pumpkin" then | |
157 | znaleziono="lampion" | |
158 | elseif blok["name"]=="minecraft:obsidian" then | |
159 | znaleziono="obsydian" | |
160 | elseif (blok["name"]=="minecraft:stained_glass") and (blok.state["color"]=="blue") then | |
161 | znaleziono="szklo_niebieskie" | |
162 | elseif (blok["name"]=="minecraft:stained_glass") and (blok.state["color"]=="red") then | |
163 | znaleziono="szklo_czerwone" | |
164 | elseif (blok["name"]=="minecraft:stained_glass") and (blok.state["color"]=="purple") then | |
165 | znaleziono="szklo_purpurowe" | |
166 | elseif (blok["name"]=="minecraft:stained_glass") and (blok.state["color"]=="yellow") then | |
167 | znaleziono="szklo_zolte" | |
168 | elseif (blok["name"]=="minecraft:stained_glass") and (blok.state["color"]=="orange") then | |
169 | znaleziono="szklo_pomaranczowe" | |
170 | else | |
171 | znaleziono="inne" | |
172 | end | |
173 | return znaleziono | |
174 | end | |
175 | ||
176 | function ruch() | |
177 | rap.fno="ruch" | |
178 | if sygnal("dol")=="ceglanetheru" then | |
179 | napisz("Jestem na linii. Zaczynam isc") | |
180 | while sygnal("dol")=="ceglanetheru" do | |
181 | if (sygnal("przod")=="lisc") or (sygnal("przod")=="snieg") then | |
182 | turtle.dig() | |
183 | end | |
184 | turtle.suck() | |
185 | turtle.forward() | |
186 | end | |
187 | napisz("Koniec linii.") | |
188 | else | |
189 | napisz("Nie jestem na linii. Nie mog isc.") | |
190 | rap.pro=1 | |
191 | end | |
192 | rap.fno="N/A" | |
193 | end | |
194 | ||
195 | function wytnijpion() | |
196 | rap.fno="wytnij_pion" | |
197 | napisz("Zaczynam funkcj? wycinki.") | |
198 | local licz=0 | |
199 | while (sygnal("przod")=="drewno") or (sygnal("gora")=="drewno") do | |
200 | turtle.dig() | |
201 | turtle.digUp() | |
202 | turtle.up() | |
203 | licz=licz+1 | |
204 | napisz("Scialem: "..licz) | |
205 | end | |
206 | while turtle.down()==true do | |
207 | end | |
208 | turtle.dig() | |
209 | rap.fno="" | |
210 | napisz("Koniec funkcji wytnij_pion") | |
211 | end | |
212 | ||
213 | function posadzswierka() | |
214 | turtle.select(16) | |
215 | slot = turtle.getItemDetail() | |
216 | if (slot.name=="minecraft:sapling") and (slot.count>4) then | |
217 | turtle.digUp() | |
218 | turtle.up() | |
219 | turtle.placeDown() | |
220 | turtle.dig() | |
221 | turtle.forward() | |
222 | turtle.placeDown() | |
223 | turtle.turnRight() | |
224 | turtle.dig() | |
225 | turtle.forward() | |
226 | turtle.placeDown() | |
227 | turtle.turnRight() | |
228 | turtle.dig() | |
229 | turtle.forward() | |
230 | turtle.placeDown() | |
231 | turtle.turnLeft() | |
232 | turtle.turnLeft() | |
233 | turtle.forward() | |
234 | turtle.dig() | |
235 | turtle.forward() | |
236 | turtle.digDown() | |
237 | turtle.down() | |
238 | else | |
239 | print("Brak sadzonek") | |
240 | turtle.turnRight() | |
241 | turtle.forward() | |
242 | turtle.turnLeft() | |
243 | turtle.forward() | |
244 | turtle.dig() | |
245 | turtle.forward() | |
246 | turtle.dig() | |
247 | turtle.forward() | |
248 | end | |
249 | turtle.select(1) | |
250 | end | |
251 | ||
252 | function wycinka() | |
253 | if sygnal("dol")=="obsydian" then | |
254 | print("Ustawiony do ciecia") | |
255 | turtle.dig() | |
256 | turtle.forward() | |
257 | wytnijpion() | |
258 | turtle.turnLeft() | |
259 | turtle.dig() | |
260 | turtle.forward() | |
261 | turtle.turnRight() | |
262 | wytnijpion() | |
263 | posadzswierka() | |
264 | else | |
265 | print("wywolano wycinke w zlym miejscu") | |
266 | program=0 | |
267 | end | |
268 | ||
269 | end | |
270 | ||
271 | function zawroc() | |
272 | if sygnal("dol")=="szklo_czerwone" then | |
273 | turtle.turnRight() | |
274 | turtle.dig() | |
275 | turtle.forward() | |
276 | turtle.turnRight() | |
277 | else | |
278 | print("F:zawroc - Nie jestem ustawiony na polu zawracania") | |
279 | end | |
280 | end | |
281 | ||
282 | function powrot() | |
283 | program=1 | |
284 | if sygnal("dol")=="szklo_purpurowe" then | |
285 | while (sygnal("dol")=="szklo_purpurowe") or (sygnal("dol")=="kamien") or (sygnal("dol")=="lampion") do | |
286 | turtle.suck() | |
287 | if (sygnal("przod")=="lisc") or (sygnal("przod")=="snieg") then | |
288 | turtle.dig() | |
289 | end | |
290 | turtle.forward() | |
291 | end | |
292 | if sygnal("dol")=="szklo_czerwone" then | |
293 | print("Koniec powrotu. Pole poprawne.") | |
294 | program=1 | |
295 | else | |
296 | print("Powrot zakonczony niepoprawnie.") | |
297 | program=0 | |
298 | end | |
299 | else | |
300 | print("Nie jestem ustawiony na starcie powrotu") | |
301 | program=0 | |
302 | end | |
303 | end | |
304 | ||
305 | function seriawycinka() | |
306 | program=1 | |
307 | if sygnal("dol")=="szklo_niebieskie" then | |
308 | turtle.dig() | |
309 | turtle.forward() | |
310 | repeat | |
311 | program=1 | |
312 | ruch() | |
313 | wycinka() | |
314 | until (program==0) or (sygnal("dol")=="szklo_czerwone") | |
315 | else | |
316 | print("Nie jestem ustawiony na starcie serii wycinki.") | |
317 | program=0 | |
318 | end | |
319 | end | |
320 | ||
321 | function czypusty() | |
322 | local licz2=1 | |
323 | local znaleziono=0 | |
324 | repeat | |
325 | if turtle.getItemCount(licz2)>0 then | |
326 | znaleziono=1 | |
327 | end | |
328 | licz2=licz2+1 | |
329 | until licz2==17 | |
330 | if znaleziono==0 then | |
331 | print("F:czypusty. Rozladowano") | |
332 | return true | |
333 | else | |
334 | print("F:czypusty. Nie rozladowano!") | |
335 | return false | |
336 | end | |
337 | end | |
338 | ||
339 | function wysyp() | |
340 | if (sygnal("dol")=="szklo_niebieskie") and (sygnal("przod")=="skrzynia") then | |
341 | local licz=1 | |
342 | repeat | |
343 | turtle.select(licz) | |
344 | turtle.drop() | |
345 | licz=licz+1 | |
346 | until licz==17 | |
347 | if czypusty()==true then | |
348 | print("F:wysyp. Material wysypany.") | |
349 | return true | |
350 | else | |
351 | print("F:wysyp. Wysypywanie nieskuteczne.") | |
352 | return false | |
353 | end | |
354 | else | |
355 | print("F:wysyp. Nie moge wysypac. Niewlasciwe pole.") | |
356 | return false | |
357 | end | |
358 | end | |
359 | ||
360 | function rozladunek() | |
361 | if sygnal("dol")=="szklo_czerwone" then | |
362 | if sygnal("przod")~="szklo" then | |
363 | repeat | |
364 | turtle.turnLeft() | |
365 | until sygal("przod")=="szklo" | |
366 | end | |
367 | turtle.turnRight() | |
368 | turtle.dig() | |
369 | turtle.forward() | |
370 | turtle.turnLeft() | |
371 | elseif sygnal("dol")=="szklo_zolte" then | |
372 | if sygnal("przod")~="skrzynia" then | |
373 | repeat | |
374 | turtle.turnLeft() | |
375 | until sygnal("przod")=="skrzynia" | |
376 | end | |
377 | turtle.turnLeft() | |
378 | turtle.dig() | |
379 | turtle.forward() | |
380 | turtle.dig() | |
381 | turtle.forward() | |
382 | turtle.dig() | |
383 | turtle.forward() | |
384 | turtle.turnRight() | |
385 | elseif sygnal("dol")=="szklo_niebieskie" then | |
386 | if sygnal("przod")~="skrzynia" then | |
387 | repeat | |
388 | turtle.turnLeft() | |
389 | until sygnal("przod")=="skrzynia" | |
390 | end | |
391 | elseif sygnal("dol")=="szklo_pomaranczowe" then | |
392 | if sygnal("przod")~="skrzynia" then | |
393 | repeat | |
394 | turtle.turnLeft() | |
395 | until sygnal("przod")=="skrzynia" | |
396 | end | |
397 | turtle.turnRight() | |
398 | turtle.dig() | |
399 | turtle.forward() | |
400 | turtle.dig() | |
401 | turtle.forward() | |
402 | turtle.turnLeft() | |
403 | else | |
404 | print("F:rozladunek. Nie stoje na pozycji do ustawiania") | |
405 | end | |
406 | ||
407 | if (sygnal("dol")=="szklo_niebieskie") and sygnal("przod")=="skrzynia" then | |
408 | wysyp() | |
409 | turtle.turnLeft() | |
410 | turtle.turnLeft() | |
411 | else | |
412 | print("F:rozladunek - nie stoje na pozycji do wysypu") | |
413 | end | |
414 | end | |
415 | ||
416 | function tankuj() | |
417 | ||
418 | if czypusty()==true then | |
419 | if (sygnal("dol")=="szklo_zolte") and (sygnal("przod")=="skrzynia") then | |
420 | print("F:tankuj. Rozpoczynam tankowanie") | |
421 | turtle.select(1) | |
422 | local tank=1 | |
423 | repeat | |
424 | turtle.suck() | |
425 | turtle.refuel() | |
426 | tank=tank+1 | |
427 | until tank==16 | |
428 | print("F:tankuj. Zakonczono tankowanie. Poziom paliwa: "..turtle.getFuelLevel()) | |
429 | else | |
430 | print("F:tankuj. Nie ustawiony do tankowania.") | |
431 | end | |
432 | else | |
433 | print("F:tankuj. Inwentaz nie oprozniony") | |
434 | end | |
435 | end | |
436 | ||
437 | ||
438 | function tankowanie() | |
439 | if turtle.getFuelLevel()<2000 then | |
440 | if sygnal("dol")=="szklo_niebieskie" then | |
441 | repeat | |
442 | turtle.turnLeft() | |
443 | until sygnal("przod")=="skrzynia" | |
444 | turtle.turnRight() | |
445 | turtle.dig() | |
446 | turtle.forward() | |
447 | turtle.dig() | |
448 | turtle.forward() | |
449 | turtle.dig() | |
450 | turtle.forward() | |
451 | turtle.turnLeft() | |
452 | tankuj() | |
453 | elseif sygnal("dol")=="szklo_czerwone" then | |
454 | repeat | |
455 | turtle.turnLeft() | |
456 | until sygnal("dol")=="szklo" | |
457 | turtle.turnRight() | |
458 | turtle.dig() | |
459 | turtle.forward() | |
460 | turtle.dig() | |
461 | turtle.forward() | |
462 | turtle.dig() | |
463 | turtle.forward() | |
464 | turtle.dig() | |
465 | turtle.forward() | |
466 | turtle.turnLeft() | |
467 | tankuj() | |
468 | elseif sygnal("dol")=="szklo_zolte" then | |
469 | repeat | |
470 | turtle.turnLeft() | |
471 | until sygnal("przod")=="skrzynia" | |
472 | tankuj() | |
473 | else | |
474 | print("F:tankowanie. Nie jestem ustawiony na pozycji wyjsciowej") | |
475 | end | |
476 | else | |
477 | print("F:tankowanie. Bak pelny. Nie ma potrzeby ustawiania") | |
478 | end | |
479 | end | |
480 | ||
481 | function ust_pobor_sadzonek() | |
482 | ||
483 | if sygnal("dol")=="szklo_zolte" then | |
484 | if sygnal("przod")~="skrzynia" then | |
485 | repeat | |
486 | turtle.turnLeft() | |
487 | until sygnal("przod")=="skrzynia" | |
488 | end | |
489 | turtle.turnLeft() | |
490 | turtle.dig() | |
491 | turtle.forward() | |
492 | turtle.dig() | |
493 | turtle.forward() | |
494 | turtle.dig() | |
495 | turtle.forward() | |
496 | turtle.dig() | |
497 | turtle.forward() | |
498 | turtle.dig() | |
499 | turtle.forward() | |
500 | turtle.turnRight() | |
501 | elseif sygnal("dol")=="szklo_niebieskie" then | |
502 | if sygnal("przod")~="skrzynia" then | |
503 | repeat | |
504 | turtle.turnLeft() | |
505 | until sygnal("przod")=="skrzynia" | |
506 | end | |
507 | turtle.turnLeft() | |
508 | turtle.dig() | |
509 | turtle.forward() | |
510 | turtle.dig() | |
511 | turtle.forward() | |
512 | turtle.turnRight() | |
513 | elseif sygnal("dol")=="szklo_czerwone" then | |
514 | if sygnal("przod")~="szklo" then | |
515 | repeat | |
516 | turtle.turnLeft() | |
517 | until sygnal("przod")=="szklo" | |
518 | end | |
519 | turtle.turnLeft() | |
520 | turtle.dig() | |
521 | turtle.forward() | |
522 | turtle.turnRight() | |
523 | elseif sygnal("dol")=="szklo_pomaranczowe" then | |
524 | if sygnal("przod")~="skrzynia" then | |
525 | repeat | |
526 | turtle.turnLeft() | |
527 | until sygnal("przod")=="skrzynia" | |
528 | end | |
529 | else | |
530 | print("ERR! (F:ust_pobor_sadzonek). Nie znajduje sie na pozycji wyjsciowej") | |
531 | end | |
532 | end | |
533 | ||
534 | function czy_brac_sadzonki() | |
535 | ||
536 | if turtle.getItemCount(16)==0 then | |
537 | print("(F:czy_brac_sadzonki). Slot pusty, mozna brac") | |
538 | return "A" | |
539 | else | |
540 | local slot=turtle.getItemDetail(16) | |
541 | if slot.name~="minecraft:sapling" then | |
542 | print("(F:czy_brac_sadzonki). Slot zajety czyms innym") | |
543 | return "B" | |
544 | elseif (slot.name=="minecraft:sapling") and turtle.getItemCount(16)>41 then | |
545 | print("(F:czy_brac_sadzonki). Wystarczajaca ilosc sadzonek") | |
546 | return "C" | |
547 | else | |
548 | print("(F:czy_brac_sadzonki) Inne - mozna brac.") | |
549 | return "D" | |
550 | end | |
551 | end | |
552 | end | |
553 | ||
554 | function ladowanie_sadzonek() | |
555 | if (sygnal("dol")=="szklo_pomaranczowe") and (sygnal("przod")=="skrzynia") then | |
556 | turtle.select(16) | |
557 | local max=turtle.getItemSpace() | |
558 | print("Brakuje: "..max) | |
559 | turtle.suck(max) | |
560 | if turtle.getItemCount(16)==0 then | |
561 | print("F:ladowanie_sadzonek - slot pusty po ladowaniu") | |
562 | else | |
563 | local slot=turtle.getItemDetail(16) | |
564 | if (slot.name=="minecraft:sapling") and (slot.count>60) then | |
565 | print("F:ladowanie_sadzonek. Zaladowano. Jest OK") | |
566 | elseif (slot.name=="minecraft:sapling") and (slot.count<60) then | |
567 | print("F:ladowanie_sadzonek. Po zaladunku mala ilosc sadzonek") | |
568 | elseif slot.name~="minecraft:sapling" then | |
569 | print("F:ladowanie_sadzonek. W slocie zly przedmiot") | |
570 | print(slot.name) | |
571 | else | |
572 | print("F:ladowanie_sadzonek. Inny wynik nieznany funkcji") | |
573 | end | |
574 | end | |
575 | else | |
576 | print("F:ladowanie_sadzonek. Ustawiony na zlym slocie") | |
577 | end | |
578 | end | |
579 | ||
580 | ||
581 | function pelnaseria() | |
582 | seriawycinka() | |
583 | zawroc() | |
584 | powrot() | |
585 | zawroc() | |
586 | rozladunek() | |
587 | tankowanie() | |
588 | end | |
589 | ||
590 | function sadzonki() | |
591 | local warunek=0 | |
592 | repeat | |
593 | ocena=czy_brac_sadzonki() | |
594 | if (ocena=="A") or (ocena=="D") then | |
595 | print("F:sadzonki - ustawiam i pobieram") | |
596 | warunek=1 | |
597 | ust_pobor_sadzonek() | |
598 | ladowanie_sadzonek() | |
599 | turtle.turnRight() | |
600 | turtle.dig() | |
601 | turtle.forward() | |
602 | turtle.dig() | |
603 | turtle.forward() | |
604 | turtle.turnRight() | |
605 | elseif ocena=="B" then | |
606 | print("F:sadzonki - slot zajety. Oprozniam") | |
607 | rozladunek() | |
608 | elseif ocena=="C" then | |
609 | print("F:sadzonki - nie ma potrzeby uzupelniania.") | |
610 | warunek=1 | |
611 | else | |
612 | print("F:sadzonki- wynik funkcji ocen nieznany") | |
613 | warunek=1 | |
614 | end | |
615 | until warunek==1 | |
616 | end | |
617 | ||
618 | function zgodanaprace() | |
619 | local odp=odpbazy("P2", 10) | |
620 | if odp=="TAK" then | |
621 | print("Otrzymalem zgode na kolejny cykl") | |
622 | aktywnosc=1 | |
623 | return true | |
624 | elseif odp=="NIE" then | |
625 | print("Otrzymalem rozkaz wstrzymania") | |
626 | aktywnosc=0 | |
627 | return true | |
628 | elseif odp=="timer" then | |
629 | print("Czas minal") | |
630 | return false | |
631 | else | |
632 | print("Inny przebieg funkcji") | |
633 | return false | |
634 | end | |
635 | end | |
636 | ||
637 | function sprawdzgotowosc() | |
638 | repeat | |
639 | until zgodanaprace()==true | |
640 | if aktywnosc==1 then | |
641 | end | |
642 | end | |
643 | ||
644 | ||
645 | function cykl() | |
646 | seriawycinka() | |
647 | zawroc() | |
648 | powrot() | |
649 | zawroc() | |
650 | rozladunek() | |
651 | tankowanie() | |
652 | sadzonki() | |
653 | end | |
654 | ||
655 | function wylaczone() | |
656 | uruchom_modem() | |
657 | while true do | |
658 | raportuj() | |
659 | turtle.forward() | |
660 | turtle.back() | |
661 | end | |
662 | end | |
663 | ||
664 | uruchom_modem() | |
665 | parallel.waitForAny(aktualizuj, raportuj) | |
666 | ||
667 | function polaczenie() | |
668 | polaczenie_z_baza("P", "1", 3, 144) | |
669 | end |