View difference between Paste ID: QBjpri97 and XsgZ1itp
SHOW: | | - or go back to the newest paste.
1-
--XsgZ1itp
1+
2-
-- pastebin get XsgZ1itp startup
2+
3
4
local firstSlot = 5 --Slots for store ore
5
local lastSlot = 12
6
7
local cobleChestSlot = 13 -- Slots for send/recive items
8
local useSlot = 14 
9
local coalChestSlot = 15
10
local enderChestSlot = 16
11
12
function emptyIfFull() --check if the turtle is full and empty it 
13
	if (turtle.getItemCount(lastSlot-1) > 0) then
14
		print("Vidange des items...")
15
		turtle.select(enderChestSlot)
16
		turtle.placeUp()
17
		sleep(0.15)
18
		for slot=firstSlot,lastSlot do
19
			turtle.select(slot)
20
			while turtle.getItemCount(slot) > 0 do
21
				turtle.dropUp(turtle.getItemCount(slot))
22
				if turtle.getItemCount(slot) > 0 then
23
					sleep(5)
24
				end
25
			end
26
		end
27
		print("Fin")
28
		turtle.select(enderChestSlot)
29
		turtle.digUp()
30
	end
31
end
32
33
function refuelIfEmpty() --fill the fuel of the turtle
34
	if turtle.getFuelLevel()<500 then
35
		print("Remplissage de Coal...")
36
		turtle.select(coalChestSlot)
37
		turtle.placeUp()
38
		turtle.select(useSlot)
39
		turtle.suckUp(32)
40
		turtle.refuel(32)
41
		print("Fin")
42
		turtle.select(coalChestSlot)
43
		turtle.digUp()
44
	end
45
end
46
47
function checkDig() --check if is not blacklisted and dig it if it's true
48
	local dig = true
49
	for slot=firstSlotBlackList,lastSlotBlackList do
50
		turtle.select(slot)
51
		if turtle.compare() then
52
			dig = false
53
		end
54
	end
55
	if dig then
56
		turtle.dig()
57
	end
58
end
59
60
function well() -- dig the well and ores
61
	local depth = 1
62
	turtle.digDown()
63
	turtle.down()
64
	turtle.digDown()
65
	while turtle.down() do
66
		for i=0,3 do
67
			turtle.turnRight()
68
			checkDig()
69
		end
70
		emptyIfFull()
71
		depth = depth+1
72
		turtle.digDown()
73
	end
74
	return depth
75
end
76
77
function up(depth)
78
	for i=1,depth do
79
		turtle.up()
80
		if turtle.getItemCount(useSlot) <=1 then
81
			turtle.select(cobleChestSlot)
82
			turtle.placeUp()
83
			turtle.select(useSlot)
84
			turtle.suckUp(64)
85
			turtle.select(cobleChestSlot)
86
			turtle.digUp()
87
			turtle.select(useSlot)
88
			turtle.placeDown()
89
		else
90
			turtle.select(useSlot)
91
			turtle.placeDown()
92
		end
93
	end
94
	turtle.select(enderChestSlot)
95
	turtle.placeUp()
96
	turtle.select(useSlot)
97
	turtle.dropUp(turtle.getItemCount(slot))
98
	turtle.select(enderChestSlot)
99
	turtle.digUp()
100
end
101
102
function nextwell() -- move to the next well
103
	for j=0,4 do
104
		turtle.forward()
105
	end
106
end
107
108
function firstWell(nb) -- move to the next well
109
	for i=1,nb do
110
		turtle.forward()
111
	end
112
end
113
114
function start(nbrPuits, turtleType)
115
	if(turtleType == 1) then
116
		print("En cours...")
117
	elseif(turtleType == 2) then
118
		firstWell(3)
119
		print("En cours...")
120
	elseif(turtleType == 3) then
121
		firstWell(1)
122
		print("En cours...")
123
	elseif(turtleType == 4) then
124
		firstWell(4)
125
		print("En cours...")
126
	else 
127
		firstWell(2)
128
		print("En cours...")
129
	end
130
	for i=1,nbrPuits do
131
		print("boucle main")
132
		refuelIfEmpty()
133
		depth = well()
134
		print("profondeur :")
135
		print(depth)
136
		up(depth)
137
		nextwell()	
138
	end
139
	print("Terminee")
140
end
141
	
142
-------------
143
--Main Prog
144
-------------
145
146
local depth = 0
147
local nbrPuits
148
local turtleType 
149
150
print("Quarry v0.1 Alpha")
151
print("Type de la turtle : 1 a 5. (Syncro)")
152
turtleType = tonumber(read())
153
print("Nombre de puits :")
154
nbrPuits = tonumber(read())
155-
if (turtleType < 1) or (turtleType>5) then
155+
if (turtleType < 1) or (turtleType>5) or (nbrPuits>64) then
156
	print("Erreur : Reboot")
157
	sleep(5)
158
	os.reboot()
159
end
160
term.clear()
161
term.setCursorPos(1,1)
162
print("Quarry v0.1 Alpha")
163-
print("Ready...")
163+
print("Run...")
164
start(nbrPuits, turtleType)