SHOW:
|
|
- or go back to the newest paste.
| 1 | --- Programme : Minage optimisé 2.0 | |
| 2 | --- Auteur : MaitreKierra | |
| 3 | --- Dernière édition : 12/04/13 | |
| 4 | --- Note : Utilisation libre. Faites en ce que vous voulez :) | |
| 5 | -- http://feed-the-beast.fr/forum/index.php?/topic/4248-turtle-minage-optimis%C3%A9-20/ | |
| 6 | ||
| 7 | --- Variables | |
| 8 | ||
| 9 | nombreLignes = 0 | |
| 10 | longueurLignes = 0 | |
| 11 | cache = 0 | |
| 12 | slot = 0 | |
| 13 | item = 0 | |
| 14 | slot = 16 | |
| 15 | ||
| 16 | --- Récupération des variables | |
| 17 | ||
| 18 | -- Nombre de lignes | |
| 19 | print("Combien de lignes fera votre turtle ?")
| |
| 20 | nombreLignes = read() | |
| 21 | nombreLignes = tonumber(nombreLignes) | |
| 22 | ||
| 23 | -- Longueur des lignes | |
| 24 | print("Quelle sera la longueur de vos tunnels ?")
| |
| 25 | cache = read() | |
| 26 | cache = tonumber(cache) | |
| 27 | ||
| 28 | --- Functions | |
| 29 | ||
| 30 | function ligne() | |
| 31 | while longueurLignes ~= 0 do | |
| 32 | turtle.dig() | |
| 33 | sleep(0.3) | |
| 34 | turtle.forward() | |
| 35 | turtle.digUp() | |
| 36 | sleep(0.3) | |
| 37 | turtle.digDown() | |
| 38 | longueurLignes = longueurLignes - 1 | |
| 39 | end | |
| 40 | end | |
| 41 | ||
| 42 | function Cache() | |
| 43 | longueurLignes = cache | |
| 44 | end | |
| 45 | ||
| 46 | function turn() | |
| 47 | turtle.turnRight() | |
| 48 | turtle.turnRight() | |
| 49 | end | |
| 50 | ||
| 51 | function Return() | |
| 52 | while longueurLignes ~= 0 do | |
| 53 | turtle.forward() | |
| 54 | longueurLignes = longueurLignes - 1 | |
| 55 | end | |
| 56 | end | |
| 57 | ||
| 58 | function nextline() | |
| 59 | sleep(0.1) | |
| 60 | turtle.turnRight() | |
| 61 | turtle.dig() | |
| 62 | turtle.digUp() | |
| 63 | sleep(0.3) | |
| 64 | turtle.forward() | |
| 65 | turtle.dig() | |
| 66 | turtle.digUp() | |
| 67 | sleep(0.3) | |
| 68 | turtle.forward() | |
| 69 | turtle.dig() | |
| 70 | turtle.digUp() | |
| 71 | sleep(0.3) | |
| 72 | turtle.forward() | |
| 73 | turtle.turnRight() | |
| 74 | end | |
| 75 | ||
| 76 | function enderchest() | |
| 77 | item = turtle.getItemCount(16) | |
| 78 | if item > 0 then | |
| 79 | turtle.select(2) | |
| 80 | turtle.dig() | |
| 81 | turtle.place() | |
| 82 | while slot ~= 1 do | |
| 83 | turtle.select(slot) | |
| 84 | turtle.drop() | |
| 85 | slot = slot - 1 | |
| 86 | end | |
| 87 | slot = 16 | |
| 88 | turtle.select(2) | |
| 89 | turtle.dig() | |
| 90 | turtle.select(1) | |
| 91 | end | |
| 92 | end | |
| 93 | ||
| 94 | function refuel() | |
| 95 | fuel = turtle.getFuelLevel() | |
| 96 | if fuel < 200 then | |
| 97 | turtle.select(1) | |
| 98 | turtle.refuel(1) | |
| 99 | end | |
| 100 | end | |
| 101 | ||
| 102 | --- Programme | |
| 103 | ||
| 104 | while nombreLignes ~= 0 do | |
| 105 | Cache() | |
| 106 | refuel() | |
| 107 | ligne() | |
| 108 | turn() | |
| 109 | Cache() | |
| 110 | Return() | |
| 111 | nextline() | |
| 112 | enderchest() | |
| 113 | nombreLignes = nombreLignes - 1 | |
| 114 | end |