View difference between Paste ID: y9WG2AGK and u4hLmUFQ
SHOW: | | - or go back to the newest paste.
1-
local temporisation = 30		--secondes à attendre entre chaque ligne
1+
	
2-
local niveauFuelMini = 100		-- niveau de déplacements auquel on doit refaire le plein de fuel
2+
3-
local niveauCharbonMini = 0		-- quantité de charbons restants à laquelle on doit refaire le plein de charbon
3+
    local temporisation = 300               --secondes åA0 attendre entre chaque ligne
4-
local niveauSaplingMini = 10
4+
    local niveauFuelMini = 100              -- niveau de dåA9placements auquel on doit refaire le plein de fuel
5-
local saplingSlot = 1
5+
    local niveauCharbonMini = 11            -- quantitåA9 de charbons restants åA0 laquelle on doit refaire le plein de charbon
6-
local premierSlot = 2                                   -- premier slot où se trouve le minerai ramassé
6+
    local niveauSaplingMini = 10
7-
local dernierSlot = 15                                  -- dernier slot à surveiller pour enclencher le vidage de l'inventaire
7+
    local saplingSlot = 1
8-
local charbonSlot = 16
8+
    local premierSlot = 2                                   -- premier slot oåB9 se trouve le minerai ramassåA9
9-
local direction = 0
9+
    local dernierSlot = 15                                  -- dernier slot åA0 surveiller pour enclencher le vidage de l'inventaire
10
    local charbonSlot = 16
11-
function verifFuel()                                    -- vérifie si on a assez de fuel (déplacements) en réserve.
11+
    local direction = 0
12-
  -- 1 charbon = 96 deplacements
12+
     
13-
  -- On vérifie le niveau de fuel
13+
    function verifFuel()                                    -- våA9rifie si on a assez de fuel (dåA9placements) en råA9serve.
14-
		local niveauFuel = turtle.getFuelLevel()
14+
      -- 1 charbon = 96 deplacements
15-
		if (niveauFuel ~= "unlimited") then
15+
      -- On våA9rifie le niveau de fuel
16-
				if (niveauFuel < niveauFuelMini) then
16+
                    local niveauFuel = turtle.getFuelLevel()
17-
						-- On a besoin de faire le plein
17+
                    if (niveauFuel ~= "unlimited") then
18-
						turtle.select(charbonSlot)
18+
                                    if (niveauFuel < niveauFuelMini) then
19-
						turtle.refuel(5) -- on recharge
19+
                                                    -- On a besoin de faire le plein
20-
						-- et on vérifie si il nous reste assez de charbon
20+
                                                    turtle.select(charbonSlot)
21-
						if turtle.getItemCount(charbonSlot) < niveauCharbonMini then
21+
                                                    turtle.refuel(5) -- on recharge
22-
								return rechargeCharbon() -- on refait le plein de charbon
22+
                                                    -- et on våA9rifie si il nous reste assez de charbon
23-
						end
23+
                                                    if turtle.getItemCount(charbonSlot) < niveauCharbonMini then
24-
				end
24+
                                                                    return rechargeCharbon() -- on refait le plein de charbon
25-
		end
25+
                                                    end
26-
end
26+
                                    end
27
                    end
28-
function rechargeSapling()
28+
    end
29
     
30-
	--on se remet en direction "un", face au coffre
30+
    function rechargeSapling()
31-
	while direction ~= 1 do
31+
     
32-
			turtle.turnRight()
32+
            --on se remet en direction "un", face au coffre
33-
			direction=direction+1
33+
            while direction ~= 1 do
34-
			if direction == 4 then direction = 0 end
34+
                            turtle.turnRight()
35-
	end
35+
                            direction=direction+1
36
                            if direction == 4 then direction = 0 end
37-
	turtle.select(saplingSlot)
37+
            end
38-
	turtle.suck()
38+
     
39
            turtle.select(saplingSlot)
40-
	--on se remet en direction "zéro"
40+
     
41-
	while direction ~= 0 do
41+
            turtle.suck(20)
42-
		turtle.turnRight()
42+
     
43-
		direction=direction+1
43+
            --on se remet en direction "zåA9ro"
44-
		if direction == 4 then direction = 0 end
44+
            while direction ~= 0 do
45-
	end
45+
                    turtle.turnRight()
46
                    direction=direction+1
47-
end
47+
                    if direction == 4 then direction = 0 end
48
            end
49-
function rechargeCharbon()
49+
     
50-
 
50+
            if turtle.getItemCount(saplingSlot) < 6 then
51-
		--on prend du charbon dans le coffre au-dessus de la tortue
51+
                    print("Merci de remettre des saplings !")
52-
		turtle.select(charbonSlot)
52+
                    print("Appuez sur ENTREE pour reprendre.")
53-
		turtle.suckUp()
53+
                    local a = read()
54-
		if turtle.getItemCount(charbonSlot) < 6 then
54+
            end
55-
			print("Merci de remettre du charbon !")
55+
     
56-
			print("Appuez sur ENTREE pour reprendre.")
56+
    end
57-
			local a = read()
57+
     
58-
		end
58+
    function rechargeCharbon()
59
     
60-
end
60+
                    --on prend du charbon dans le coffre au-dessus de la tortue
61
                    turtle.select(charbonSlot)
62-
function videInventaire()
62+
                    turtle.suckUp()
63-
 	   
63+
                    if turtle.getItemCount(charbonSlot) < 6 then
64-
		--on se remet en direction "deux", face au coffre
64+
                            print("Merci de remettre du charbon !")
65-
		while direction ~= 2 do
65+
                            print("Appuez sur ENTREE pour reprendre.")
66-
				turtle.turnRight()
66+
                            local a = read()
67-
				direction=direction+1
67+
                    end
68-
				if direction == 4 then direction = 0 end
68+
                    turtle.select(charbonSlot)
69-
		end
69+
                    turtle.refuel(5) -- on recharge
70-
	   
70+
    end
71-
		--on vide l'inventaire
71+
     
72-
		for slot=premierSlot,dernierSlot do
72+
    function videInventaire()
73-
				turtle.select(slot)
73+
               
74-
				while turtle.getItemCount(slot) > 0 do
74+
                    --on se remet en direction "deux", face au coffre
75-
						turtle.drop(turtle.getItemCount(slot))
75+
                    --while direction ~= 2 do
76-
						if turtle.getItemCount(slot) > 0 then
76+
                            --      turtle.turnRight()
77-
								sleep(0.5)
77+
                            --      direction=direction+1
78-
						end
78+
                            --      if direction == 4 then direction = 0 end
79-
				end
79+
                    --end
80-
		end
80+
               
81-
	   
81+
                    --on vide l'inventaire
82-
		--on se remet en direction "zéro"
82+
                    for slot=premierSlot,dernierSlot do
83-
		while direction ~= 0 do
83+
                                    turtle.select(slot)
84-
				turtle.turnRight()
84+
                                    while turtle.getItemCount(slot) > 0 do
85-
				direction=direction+1
85+
                                                    turtle.drop(turtle.getItemCount(slot))
86-
				if direction == 4 then direction = 0 end
86+
                                                    if turtle.getItemCount(slot) > 0 then
87-
		end
87+
                                                                    sleep(0.5)
88
                                                    end
89-
end
89+
                                    end
90
                    end
91-
verifFuel()
91+
               
92-
turtle.forward()
92+
                    --on se remet en direction "zåA9ro"
93-
while true do
93+
                    --while direction ~= 0 do
94-
	turtle.select(1)
94+
                            --      turtle.turnRight()
95-
	turtle.turnRight()
95+
                            --      direction=direction+1
96-
	if turtle.compare() == false then
96+
                            --      if direction == 4 then direction = 0 end
97-
		for i=1,8 do
97+
                    --end
98-
			turtle.dig()
98+
     
99-
			if i ~= 8 then
99+
    end
100-
				turtle.digUp()
100+
     
101-
				turtle.up()
101+
     
102-
			end
102+
    verifFuel()
103-
		end
103+
    turtle.forward()
104-
		for i=1,7 do
104+
    while true do
105-
			turtle.down()
105+
            turtle.select(1)
106-
		end
106+
            turtle.turnRight()
107-
		turtle.place()
107+
            if turtle.compare() == false then
108-
	end
108+
                    for i=1,8 do
109-
	turtle.turnLeft()
109+
                            turtle.dig()
110-
	for i=1, 3 do
110+
                            if i ~= 8 then
111-
		if turtle.forward() == false then
111+
                                    turtle.digUp()
112-
			turtle.turnLeft()
112+
                                    turtle.up()
113-
			turtle.forward()
113+
                            end
114-
			turtle.turnLeft()
114+
                    end
115-
			verifFuel()
115+
                    for i=1,7 do
116-
			if turtle.getItemCount(dernierSlot) > 0 then
116+
                            turtle.down()
117-
				videInventaire()
117+
                    end
118-
			end
118+
                    turtle.suck()
119-
			if turtle.getItemCount(saplingSlot) < niveauSaplingMini then
119+
                    turtle.place()
120-
				rechargeSapling()
120+
            end
121-
			end
121+
            turtle.turnLeft()
122-
			sleep(temporisation)
122+
            for i=1, 3 do
123-
			turtle.forward()
123+
                    if turtle.forward() == false then
124-
			break
124+
                            turtle.turnLeft()
125-
		end
125+
                            turtle.forward()
126-
	end
126+
                            turtle.turnLeft()
127-
	sleep(0.1)
127+
                            verifFuel()
128-
end
128+
                            --if turtle.getItemCount(dernierSlot) > 0 then
129
                            videInventaire()
130
                            --end
131
                            if turtle.getItemCount(saplingSlot) < niveauSaplingMini then
132
                                    rechargeSapling()
133
                            end
134
                            sleep(temporisation)
135
                            turtle.forward()
136
                            break
137
                    end
138
            end
139
            sleep(0.1)
140
    end