SHOW:
|
|
- or go back to the newest paste.
1 | -- Tanken | |
2 | local function refuel() | |
3 | local fuelLevel = turtle.getFuelLevel() | |
4 | if fuelLevel == "unlimited" or fuelLevel > 0 then | |
5 | return | |
6 | end | |
7 | ||
8 | local function tryRefuel() | |
9 | for n=13,16 do | |
10 | if turtle.getItemCount(n) > 0 then | |
11 | turtle.select(n) | |
12 | if turtle.refuel(1) then | |
13 | turtle.select(1) | |
14 | return true | |
15 | end | |
16 | end | |
17 | end | |
18 | turtle.select(1) | |
19 | return false | |
20 | end | |
21 | ||
22 | if not tryRefuel() then | |
23 | print( "Add more fuel to continue." ) | |
24 | while not tryRefuel() do | |
25 | sleep(1) | |
26 | end | |
27 | print( "Resuming Tunnel." ) | |
28 | end | |
29 | end | |
30 | ||
31 | --Samen Nachlegen() | |
32 | function Nachlegen() | |
33 | aa = turtle.getItemCount(fach) | |
34 | - | if aa == 0 then |
34 | + | if aa < 8 then |
35 | fach = fach+1 | |
36 | if fach == 12 then | |
37 | print("Error - Nicht genug Samen vorhanden!!!!") | |
38 | return false | |
39 | end | |
40 | turtle.select(fach) | |
41 | end | |
42 | - | for i = 1,8,1 do |
42 | + | |
43 | ||
44 | --Auswerfen | |
45 | function Auswerfen() | |
46 | for i = 1,8 do | |
47 | turtle.select(i) | |
48 | turtle.dropDown() | |
49 | end | |
50 | end | |
51 | ||
52 | --Samen neu bestuecken | |
53 | function Samen() | |
54 | turtle.select(1) | |
55 | turtle.suckDown() | |
56 | turtle.select(2) | |
57 | turtle.suckDown() | |
58 | end | |
59 | ||
60 | --Brennmaterial neu bestuecken | |
61 | function Brenn() | |
62 | turtle.select(16) | |
63 | turtle.suckUp() | |
64 | end | |
65 | ||
66 | --Vor | |
67 | - | turtle.select(1) |
67 | + | |
68 | refuel() | |
69 | turtle.forward() | |
70 | turtle.forward() | |
71 | Nachlegen() | |
72 | turtle.digDown() | |
73 | turtle.placeDown() | |
74 | end | |
75 | ||
76 | --Back | |
77 | function Back() | |
78 | refuel() | |
79 | turtle.turnLeft() | |
80 | turtle.back() | |
81 | turtle.back() | |
82 | end | |
83 | ||
84 | -- GoBack() | |
85 | function GoBack() | |
86 | print(" Arbeit erledigt ") | |
87 | print(" Gehe nun Heim ") | |
88 | turtle.turnLeft() | |
89 | while breit3 > 0 do | |
90 | refuel() | |
91 | turtle.forward() | |
92 | breit3 = breit3 -1 | |
93 | print(breit," ",breit2," ",breit3) | |
94 | end | |
95 | end | |
96 | ||
97 | function Titel() | |
98 | shell.run("clear") | |
99 | print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") | |
100 | print("{ }") | |
101 | print("{ Weizenfarm }") | |
102 | print("{ }") | |
103 | print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") | |
104 | print() | |
105 | sleep(1) | |
106 | end | |
107 | ||
108 | - | lang = tonumber(8) |
108 | + | |
109 | ||
110 | --Variablen | |
111 | lang = tonumber(16) | |
112 | lang2 = lang | |
113 | breit = tonumber(8) | |
114 | breit2 = breit | |
115 | breit3 = breit -1 | |
116 | ausrichtung = "links" | |
117 | fach = 1 | |
118 | function Ausrichtung() | |
119 | if ausrichtung == "links" then | |
120 | refuel() | |
121 | turtle.turnLeft() | |
122 | turtle.forward() | |
123 | -- turtle.digDown() | |
124 | -- turtle.placeDown() | |
125 | --turtle.forward() | |
126 | turtle.turnLeft() | |
127 | ausrichtung = "rechts" | |
128 | else | |
129 | refuel() | |
130 | turtle.turnRight() | |
131 | turtle.forward() | |
132 | -- turtle.digDown() | |
133 | -- turtle.placeDown() | |
134 | --turtle.forward() | |
135 | turtle.turnRight() | |
136 | ausrichtung = "links" | |
137 | end | |
138 | end | |
139 | - | turtle.select(1) |
139 | + | |
140 | function Saehen() | |
141 | - | -- turtle.placeDown() |
141 | + | |
142 | Nachlegen() | |
143 | -- turtle.digDown() | |
144 | turtle.placeDown() | |
145 | while lang > 1 do | |
146 | Nachlegen() | |
147 | turtle.forward() | |
148 | turtle.digDown() | |
149 | turtle.placeDown() | |
150 | --turtle.forward() | |
151 | lang = lang-1 | |
152 | end | |
153 | lang = lang2 | |
154 | end | |
155 | ||
156 | Titel() | |
157 | print("Programm laeuft") | |
158 | sleep(1) | |
159 | print("Samen wird aufgeladen") | |
160 | Samen() | |
161 | sleep(1) | |
162 | print("Brennmaterial wird geladen") | |
163 | Brenn() | |
164 | sleep(1) | |
165 | print("Bewege mich zum Arbeitsgebiet") | |
166 | Vor() | |
167 | while breit > 0 do | |
168 | Saehen() | |
169 | breit = breit-1 | |
170 | if breit > 0 then | |
171 | Ausrichtung() | |
172 | end | |
173 | end | |
174 | GoBack() | |
175 | Back() | |
176 | Auswerfen() | |
177 | --os.reboot() |