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