Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x3 = 0
- y3 = 0
- orientation = 0
- z3 = 0
- print("Longeur :")
- --x = tonumber(read())
- print("Largeur :")
- z = tonumber(read())
- function afficheinfo()
- term.clear()
- print("X:"..x3)
- print("Y:"..y3)
- print("Z:"..z3)
- 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()
- else
- turtle.down()
- y3 = y3-1
- afficheinfo()
- end
- else
- if not turtle.up() then
- turtle.digUp()
- else
- turtle.up()
- y3 = y3+1
- afficheinfo()
- end
- end
- end
- end
- function deplacementZ(z2)
- z2 = tonumber(z2)
- if z3 > z2 then
- Corientation(1)
- else
- Corientation(3)
- end
- while z3 ~= z2 do
- if not turtle.forward() then
- turtle.dig()
- turtle.forward()
- if orientation == 3 then
- z3 = z3+1
- afficheinfo()
- elseif orientation == 1 then
- z3 = z3-1
- afficheinfo()
- end
- else
- turtle.forward()
- 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()
- turtle.forward()
- if orientation == 0 then
- x3 = x3+1
- afficheinfo()
- elseif orientation == 2 then
- x3 = x3-1
- afficheinfo()
- end
- else
- turtle.forward()
- 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()
- 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
- deplacement(XT,YT,ZT)
- end
- deplacement(0,0,2)
- vidage()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement