Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x3 = 0
- yam = 0
- xam = 0
- zam = 0
- ybu = 0
- xbu = 0
- zbu = 0
- y3 = 0
- orientation = 0
- z3 = 0
- print("Longeur :")
- xbu = tostring(read())
- xbu = tonumber(xbu)
- print("Largeur :")
- zbu = tostring(read())
- zbu = tonumber(zbu)
- --zbu = 4
- print("hauteur : ")
- ybu = tonumber(read())
- function afficheinfo()
- term.clear()
- print("X:"..x3)
- print("Y:"..y3)
- print("Z:"..z3)
- print(pair)
- print(zbu)
- print(vidage1)
- print("orientation:"..orientation)
- end
- function Corientation(o)
- while orientation ~= o do
- turtle.turnLeft()
- orientation = orientation+1
- if orientation == 4 then
- orientation = 0
- end
- afficheinfo()
- end
- end
- function deplacementY(y2)
- yb = tonumber(y2)
- while yb ~= y3 do
- if yb < y3 then
- if not turtle.down() then
- turtle.digDown()
- if turtle.getItemCount(15) > 0 then
- vidage()
- end
- else
- y3 = y3-1
- afficheinfo()
- end
- else
- if not turtle.up() then
- turtle.digUp()
- if turtle.getItemCount(15) > 0 then
- vidage()
- end
- else
- y3 = y3+1
- afficheinfo()
- end
- end
- end
- end
- function deplacementZ(z2)
- if z3 > z2 then
- Corientation(1)
- else
- Corientation(3)
- end
- while z3 ~= z2 do
- if not turtle.forward() then
- turtle.dig()
- if turtle.getItemCount(15) > 0 then
- vidage()
- end
- else
- if orientation == 3 then
- z3 = z3+1
- afficheinfo()
- elseif orientation == 1 then
- z3 = z3-1
- afficheinfo()
- end
- end
- end
- end
- function deplacementX(x2)
- if x3 > x2 then
- Corientation(2)
- else
- Corientation(0)
- end
- while x3 ~= x2 do
- if not turtle.forward() then
- turtle.dig()
- if turtle.getItemCount(15) > 0 then
- vidage()
- end
- else
- print("h")
- afficheinfo()
- if orientation == 0 then
- x3 = x3+1
- afficheinfo()
- elseif orientation == 2 then
- x3 = x3-1
- afficheinfo()
- end
- end
- end
- end
- function deplacement(xa,ya,za)
- deplacementY(ya)
- deplacementX(xa)
- deplacementZ(za)
- end
- function vidage()
- vidage1 = true
- print("vidage")
- XT = x3
- YT = y3
- ZT = z3
- deplacement(0,0,0)
- Corientation(2)
- for slot=1,15 do
- turtle.select(slot)
- while turtle.getItemCount(slot) > 0 do
- turtle.drop(turtle.getItemCount(slot))
- if turtle.getItemCount(slot) > 0 then
- sleep(0.5)
- end
- end
- end
- turtle.select(1)
- deplacement(1,YT,ZT)
- vidage1 = false
- end
- function minage()
- pair = true
- repeat
- repeat
- if pair == false then
- but = 1
- if x3 == xbu then
- deplacementX(1)
- else
- deplacementX(xbu)
- end
- deplacementZ(z3-1)
- elseif pair == true then
- but = zbu
- if x3 == xbu then
- deplacementX(1)
- else
- deplacementX(xbu)
- end
- deplacementZ(z3+1)
- end
- until z3 == but
- if x3 == 1 then
- deplacementX(xbu)
- else
- deplacementX(1)
- end
- if pair == true then
- pair = false
- elseif pair == false then
- pair = true
- end
- if y3 == ybu then
- break
- else
- deplacementY(y3+1)
- end
- until y3 >= ybu
- deplacement(0,0,0)
- Corientation(0)
- end
- deplacement(1,1,4)
- vidage()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement