• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled a guest Apr 8th, 2020 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. --Local
2. local distance = 0 -- How Far Did User Pick
3. local onlight = 0 -- When to Place Torch
4. local torch = turtle.getItemCount(1) -- How many items are in slot 1 (torch)
5. local chest = turtle.getItemCount(2) -- How many items are in slot 2 (chest)
6. local ItemFuel = turtle.getItemCount(3) -- How many items are in slot 3 (Fuel)
7. local MD = 3 -- How Many Blocks Apart From Each Mine
8. local MineTimes = 0 -- If Multi Mines Are ON then This will keep Count
9. local Fuel = 0 -- if 2 then it is unlimited no fuel needed
10. local NeedFuel = 0 -- If Fuel Need Then 1 if not Then 0
11. local Error = 0 -- 0 = No Error and 1 = Error
12. local Way = 0 -- 0 = Left and 1 = Right
13.
14. --Checking
15. local function Check()
16.   if torch == 0 then
17.     print("Please place torches in slot 1")
18.     Error = 1
19.   end
20.
21.   if chest == 0 then
22.     print("Please place chests in slot 2")
23.     Error = 1
24.   end
25.
26.     if ItemFuel == 0 then
27.     print("Please place fuel in slot 3")
28.         Error = 1
29.     end
30.
31.   repeat
32.     if turtle.getFuelLevel() < 100 then
33.       turtle.select(3)
34.       turtle.refuel(1)
35.       NeedFuel = 1
36.       ItemFuel -= 1
37.     end
38.   until NeedFuel == 0
39. end
40.
41. -- Recheck if user forget something turtle will check after 15 sec
42. local function Recheck()
43.     torch = turtle.getItemCount(1)
44.     chest = turtle.getItemCount(2)
45.     ItemFuel = turtle.getItemCount(3)
46.     Error = 0
47. end
48.
49. --Mining
50. local function ForwardM()
51.     repeat
52.         if turtle.detect() then
53.             turtle.dig()
54.         end
55.
56.         if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
57.             TF -= 1
58.       onlight += 1
59.         end
60.
61.     if turtle.detectUp() then
62.             turtle.digUp()
63.         end
64.
65.     if turtle.detectDown() then
66.       turtle.digDown()
67.     end
68.
69.         if onlight == 8 then -- Every 10 Block turtle place torch
70.             if torch > 0 then
71.         turtle.turnRight()
72.         turtle.dig()
73.         turtle.select(1)
74.         turtle.place()
75.         turtle.turnLeft()
76.
77.         torch -= 1
78.         onlight -= 8
79.             else
81.                 os.shutdown()
82.             end
83.         end
84.
85.         if turtle.getItemCount(16) > 0 then -- If slot 16 in turtle has item slot 5 to 16 will go to chest
86.             if chest > 0 then
87.         turtle.turnRight()
88.         turtle.dig()
89.         turtle.up()
90.         turtle.dig()
91.         turtle.down()
92.         turtle.select(2)
93.         turtle.place()
94.
95.         chest -= 1
96.
97.         for slot = 5, 16 do
98.           turtle.select(slot)
99.           turtle.drop()
100.           sleep(1.5)
101.         end
102.
103.                 turtle.select(5)
104.             else
105.         print("Please place more chests in the turtle...")
106.                 os.shutdown()
107.             end
108.         end
109.
110.         repeat
111.       if turtle.getFuelLevel() < 100 then
112.         turtle.select(3)
113.         turtle.refuel(1)
114.         NeedFuel = 1
115.         ItemFuel -= 1
116.       elseif ItemFuel == 0 then
117.         print("Please place fueld in the turtle...")
118.         os.shutdown()
119.       elseif NeedFuel == 1 then
120.         NeedFuel = 0
121.       end
122.         until NeedFuel == 0
123.     until TF == 0
124. end
125.
126. --Warm Up For Back Program
127. local function WarmUpForBackProgram() -- To make turn around so it can go back
128.     turtle.turnLeft()
129.     turtle.turnLeft()
130.     turtle.up()
131. end
132.
133. --Back Program
134. local function Back()
135.     repeat
136.         if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
137.             TB = TB - 1
138.         end
139.         if turtle.detect() then -- Sometimes sand and gravel can happen and this will fix it
140.             if TB ~= 0 then
141.                 turtle.dig()
142.             end
143.         end
144.     until TB == 0
145. end
146.
147. -- Multimines Program
148. local function MultiMines()
149.     if Way == 1 then
150.         turtle.turnLeft()
151.         turtle.down()
152.     else
153.         turtle.turnRight()
154.         turtle.down()
155.     end
156.     repeat
157.         if turtle.detect() then
158.             turtle.dig()
159.         end
160.         if turtle.forward() then
161.             MD = MD - 1
162.         end
163.         if turtle.detectUp() then
164.             turtle.digUp()
165.         end
166.     until MD == 0
167.     if Way == 1 then
168.         turtle.turnLeft()
169.     else
170.         turtle.turnRight()
171.     end
172.     if MineTimes == 0 then
173.         print("Turtle is done")
174.     else
175.         MineTimes = MineTimes - 1
176.     end
177. end
178.
179. -- Restart
180. local function Restart()
181.     TF = distance
182.     TB = distance
183.     MD = 3
184.     onlight = 0
185. end
186.
187. -- Starting
188. function Start()
189.     repeat
190.         ForwardM()
191.         WarmUpForBackProgram()
192.         Back()
193.         MultiMines()
194.         Restart()
195.     until MineTimes == 0
196. end
197.
198. -- Start
199. print("Hi There Welcome to Mining Turtle Program")
200. print("How Far Will Turtle Go")
202. distance = tonumber(input)
203. TF = distance
204. TB = distance
205. print("Left or Right")
206. print("0 = Left and 1 = Right")
208. Way = tonumber(input2)
209. print("How Many Times")