﻿

# Mine Turtli

Nov 28th, 2020 (edited)
304
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. local fackelabstand = 8
2. local fackelzaehler = 0
3. local invposfackel = 0
4. local invposchest = 0
5. local invposcoal = 0
6.
7. function vor()
8.     while not turtle.forward() do
9.         turtle.dig()
10.     end
11.     while turtle.detectUp() do
12.         turtle.digUp()
13.     end
14.     turtle.digDown()
15.     if turtle.getFuelLevel() < 10 then
16.         turtle.select(invposcoal)
17.         turtle.refuel()
18.         turtle.select(1)
19.     end
20. end
21.
22. function fackel()
23.     if (fackelzaehler>=fackelabstand) and (invposfackel ~=0) then
24.         turtle.turnRight()
25.         turtle.turnRight()
26.         turtle.down()
27.         turtle.select(invposfackel)
28.         if turtle.place() then
29.             fackelzaehler = 0
30.             if turtle.getItemCount(invposfackel) == 0 then
31.                 invposfackel = 0
32.             end
33.         else
34.             fackelzaehler = fackelzaehler-2
35.         end
36.         turtle.select(1)
37.         turtle.up()
38.         turtle.turnRight()
39.         turtle.turnRight()
40.     else
41.         fackelzaehler = fackelzaehler+1
42.     end
43. end
44.
45. function gang()
46.     for j=1,laenge do
47.         vor()
48.         fackel()
49.     end
50. end
51.
53.     for q=1,16 do
54.         if (q ~= invposchest) and (q ~= invposcoal) and (q ~= invposfackel) then
55.             turtle.select(q)
56.             turtle.drop()
57.         end
58.     end
59. end
60.
61. function voll()
62.     if (turtle.getItemCount(13)>0) and (invposchest ~= 0) then
63.         turtle.dig()
64.         turtle.down()
65.         turtle.dig()
66.         turtle.select(invposchest)
67.         turtle.place()
69.         turtle.up()
70.         turtle.select(1)
71.     end
72. end
73.
74. function quer()
75.     for k=1,abstand do
76.         vor()
77.         fackel()
78.     end
79. end
80.
81. function drehen(currentGang)
82.     if richtung == "r" then
83.         turtle.turnRight()
84.         quer()
85.         turtle.turnRight()
86.         richtung = "l"
87.         if currentGang > 0 then
88.             write("Gang ")
89.             write(currentGang)
90.             write(" fertig.\n")
91.         end
92.     else
93.         turtle.turnLeft()
94.         quer()
95.         turtle.turnLeft()
96.         richtung = "r"
97.         if currentGang > 0 then
98.             write("Gang ")
99.             write(currentGang)
100.             write(" fertig.\n")
101.         end
102.     end
103. end
104.
105. function invcheck()
106.     for l=1,16 do
107.         data = turtle.getItemDetail(l)
108.         if data then
109.             if data.name == "minecraft:torch" then
110.                 invposfackel = l
111.             elseif data.name == "minecraft:chest" then
112.                 invposchest = l
113.             elseif data.name == "minecraft:coal" then
114.                 invposcoal = l
115.             end
116.         end
117.     end
118. end
119.
120. function invsort()
121.     if (invposcoal ~= 0) and (invposcoal ~= 1) then
122.         turtle.select(invposcoal)
123.         if turtle.transferTo(1) then
124.             invposcoal = 1
125.         end
126.     end
127.     if (invposfackel ~= 0) and (invposfackel ~= 2) then
128.         turtle.select(invposfackel)
129.         if turtle.transferTo(2) then
130.             invposfackel = 2
131.         end
132.     end
133.     if (invposchest ~= 0) and (invposchest ~= 3) then
134.         turtle.select(invposchest)
135.         if turtle.transferTo(3) then
136.             invposchest = 3
137.         end
138.     end
139.     turtle.select(1)
140. end
141.
142. function fuelcheck()
143.     needed = (laenge+abstand)*anzahl*2
144.     if turtle.getFuelLevel() < needed then
145.         if invposcoal == 0 then
146.             write("[Fuelcheck] !!!ACHTUNG!!! Treibstoff nicht ausreichend\n")
147.         else
148.             diff = needed - turtle.getFuelLevel()
149.             if turtle.getItemCount(invposcoal) >= (diff/80) then
150.                 turtle.select(invposcoal)
151.                 while turtle.getFuelLevel() < needed do
152.                     turtle.refuel()
153.                 end
154.                 write("[Fuelcheck] Treibstoff nachgefüllt\n")
155.             else
156.                 write("[Fuelcheck] !!!ACHTUNG!!! Treibstoff nicht ausreichend\n")
157.             end
158.         end
159.     else
160.         write("[Fuelcheck] Treibstoff ausreichend\n")
161.     end
162.     write("Abbrechen mit 'x', sonst start... ")
164.     if auswahl == "x" then
165.         error()
166.     end
167. end
168.
169. -- MAIN
170. term.clear()
171. write("Im Hauptgang links oder rechts in Kopfhöhe an die Wand setzen\n")
172. write("Fackeln, Kisten, Kohle ins Inventar\n")
173. write("!!!UNTERSTE REIHE BLEIBT FREI!!!\n")
174.
175. write("\nLaenge der Gänge: ")
177.
178. write("Abstand der Gänge: ")
180. abstand = abstand+1
181. --abstand = 3
182. if abstand >= 0 then
183.     fackelabstand = (((laenge*2)/100)*70)
184. end
185.
186. write("Anzahl der Gangpaare (hin-zurück): ")
188.
189. write("\nIn welche Richtung fortfahren?\n")
190. write("rechts (r) oder links (l): ")
192. term.clear()
193. fuelcheck()
194. for i=1,anzahl do
195.     invcheck()
196.     invsort()
197.     gang()
198.     voll()
199.     invcheck()
200.     invsort()
201.     drehen(0)
202.     gang()
203.     voll()
204.     drehen(i)
205. end
RAW Paste Data