-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStrip_Mine.lua
More file actions
227 lines (217 loc) · 4.68 KB
/
Strip_Mine.lua
File metadata and controls
227 lines (217 loc) · 4.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
-- This Version
-- 1.0 18/01/21
-- ChangeLogs
--
-- ToDoList
--
--Local
local distance = 0 -- How Far Did User Pick
local onlight = 0 -- When to Place Torch
local torch = turtle.getItemCount(1) -- How many items are in slot 1 (torch)
local chest = turtle.getItemCount(2) -- How many items are in slot 2 (chest)
local ItemFuel = turtle.getItemCount(3) -- How many items are in slot 3 (Fuel)
local MD = 3 -- How Many Blocks Apart From Each Mine
local MineTimes = 0 -- If Multi Mines Are ON then This will keep Count
local Fuel = 0 -- if 2 then it is unlimited no fuel needed
local NeedFuel = 0 -- If Fuel Need Then 1 if not Then 0
local Error = 0 -- 0 = No Error and 1 = Error
local Way = 0 -- 0 = Left and 1 = Right
--Checking
local function Check()
if torch == 0 then
print("There are no torch's in Turtle")
Error = 1
else
print("There are torch's in turtle")
end
if chest == 0 then
print("there are no chests")
Error = 1
else
print("There are chest in turtle")
end
if ItemFuel == 0 then
print("No Fuel Items")
Error = 1
else
print("there is fuel")
end
repeat
if turtle.getFuelLevel() == "unlimited" then
print("NO NEED FOR FUEL")
Needfuel = 0
elseif turtle.getFuelLevel() < 100 then
turtle.select(3)
turtle.refuel(1)
Needfuel = 1
ItemFuel = ItemFuel - 1
elseif NeedFuel == 1 then
Needfuel = 0
end
until NeedFuel == 0
end
-- Recheck if user forget something turtle will check after 15 sec
local function Recheck()
torch = turtle.getItemCount(1)
chest = turtle.getItemCount(2)
ItemFuel = turtle.getItemCount(3)
Error = 0
end
--Mining
local function ForwardM()
repeat
if turtle.detect() then
turtle.dig()
end
if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
TF = TF - 1
onlight = onlight + 1
end
if turtle.detectUp() then
turtle.digUp()
end
turtle.select(4)
turtle.placeDown()
if onlight == 8 then -- Every 10 Block turtle place torch
if torch > 0 then
turtle.turnLeft()
turtle.turnLeft()
turtle.select(1)
turtle.place()
turtle.turnLeft()
turtle.turnLeft()
torch = torch - 1
onlight = onlight - 8
else
print("turtle run out of torchs")
os.shutdown()
end
end
if turtle.getItemCount(16)>0 then -- If slot 16 in turtle has item slot 5 to 16 will go to chest
if chest > 0 then
turtle.select(2)
turtle.digDown()
turtle.placeDown()
chest = chest - 1
for slot = 5, 16 do
turtle.select(slot)
turtle.dropDown()
sleep(1.5)
end
turtle.select(5)
else
print("turtle run out of chest")
os.shutdown()
end
end
repeat
if turtle.getFuelLevel() == "unlimited" then
print("NO NEED FOR FUEL")
Needfuel = 0
elseif turtle.getFuelLevel() < 100 then
turtle.select(3)
turtle.refuel(1)
Needfuel = 1
ItemFuel = ItemFuel - 1
elseif ItemFuel == 0 then
print("turtle run out of fuel")
os.shutdown()
elseif NeedFuel == 1 then
Needfuel = 0
end
until NeedFuel == 0
until TF == 0
end
--Warm Up For Back Program
local function WarmUpForBackProgram() -- To make turn around so it can go back
turtle.turnLeft()
turtle.turnLeft()
turtle.up()
end
--Back Program
local function Back()
repeat
if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
TB = TB - 1
end
if turtle.detect() then -- Sometimes sand and gravel can happen and this will fix it
if TB ~= 0 then
turtle.dig()
end
end
until TB == 0
end
-- Multimines Program
local function MultiMines()
if Way == 1 then
turtle.turnLeft()
turtle.down()
else
turtle.turnRight()
turtle.down()
end
repeat
if turtle.detect() then
turtle.dig()
end
if turtle.forward() then
MD = MD - 1
end
if turtle.detectUp() then
turtle.digUp()
end
until MD == 0
if Way == 1 then
turtle.turnLeft()
else
turtle.turnRight()
end
if MineTimes == 0 then
print("Turtle is done")
else
MineTimes = MineTimes - 1
end
end
-- Restart
local function Restart()
TF = distance
TB = distance
MD = 3
onlight = 0
end
-- Starting
function Start()
repeat
ForwardM()
WarmUpForBackProgram()
Back()
MultiMines()
Restart()
until MineTimes == 0
end
-- Start
print("Hi There Welcome to Mining Turtle Program")
print("Slot 1 = Torch, Slot 2 = Chest, Slot 3 = Fuel, Slot 4 = Cobble")
--print("How Far Will Turtle Go")
--input = io.read()
--distance = tonumber(input)
distance = 15
TF = distance
TB = distance
print("Left or Right")
print("0 = Left and 1 = Right")
input2 = io.read()
Way = tonumber(input2)
--print("How Many Times")
--input3 = io.read()
--MineTimes = tonumber(input3)
MineTimes = 5
Check()
if Error == 1 then
repeat
sleep(10)
Recheck()
Check()
until Error == 0
end
Start()