View difference between Paste ID: D6KaQp8u and bjrSN4Qc
SHOW: | | - or go back to the newest paste.
1
--           Variables 
2
3
-- slots
4
5
local slot = 0
6
local slotActuel = 0 
7
local slotsMax = 16
8
local nbItemSlot = 0
9
10
-- bucket
11
12
local bucketSlot = 0
13
local bucketSlotFound = false;
14
local bucketEmpty = "minecraft:bucket"
15
local bucketFull = "minecraft:water_bucket"
16
local bucketPlein = false;
17
local bucketFound = false;
18
19
20
--          Fonctions
21
22
-- Main
23
24
function main()
25
26
findBucketSlot()
27
28
end
29
30
-- Slot 
31
32
function selectSlot(a)
33
34
	turtle.select(a)
35
	majSlot()
36
37
end
38
39
function majSlot()  -- A LANCER APRES CHAQUE DEPLACEMENT
40
41
slotActuel = turtle.getSelectedSlot()
42
	
43
	if itemInSlot() then
44
	slot = turtle.getItemDetail()
45
	end
46
47
48
end
49
50
function firstSlot()
51
52
	selectSlot(1)
53
54
end
55
56
function upSlot()
57
	
58
	selectSlot(slotActuel + 1)
59
60
end
61
62
63
64
function slotIsBucket()
65
66
	if slot.name == bucketEmpty or slot.name == bucketFull then
67
	return true
68
	else
69
	return false
70
	end
71
72
73
end
74
75
76
function itemInSlot()
77
78
	nbItemSlot = turtle.getItemCount()
79
80
	if nbItemSlot > 0 then
81
	return true
82
	else
83
	return false
84
	end
85
86
end
87
88
89
-- Bucket
90
91
function bucketCheckSlot()
92
	
93
	if itemInSlot() then
94
		
95
		if slotIsBucket() then
96
		bucketFound = true
97
		print("BUCKET FOUND")
98
		else
99
		end
100
	end
101
end
102
103
function findBucketSlot()
104
105
firstSlot()
106
107
	while not bucketFound do
108
	bucketCheckSlot()
109
	upSlot()
110
	end
111
112
113
end
114
115
116
function bEtat()
117
118
	selectSlot(bucketSlot)
119
120
	if bIsEmpty() then 
121
	bucketPlein = false;
122
	
123
	elseif bIsFull() then
124
	bucketPlein = true;
125
126
	end 
127
	
128
129
end
130
131
function bIsEmpty()
132
133
	if slot.name == bucketEmpty then
134
	
135
	return true
136
	else
137
	return false
138
	end
139
140
end
141
142
143
function bIsFull()
144
145
	if slot.name == bucketFull then
146
147
	return true
148
	else
149
	return false
150
	end
151
152
end
153
154
155
156
-- exec
157
158
main()