Advertisement
Guest User

m

a guest
Dec 10th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | None | 0 0
  1. local x = 0
  2. local y = 0
  3. orientation = 0
  4. local z = 0
  5. print("Longeur :")
  6. --x = tonumber(read())
  7. print("Largeur :")
  8. z = tonumber(read())
  9. function Corientation(o)
  10.     while orientation ~= o do
  11. turtle.turnLeft()
  12. orientation = orientation+1
  13. if orientation == 4 then
  14. orientation = 0
  15. end
  16. print(tonumber(orientation))
  17. end
  18. end
  19. function deplacement(x1,z1)
  20. x1 = tonumber(x1)
  21. z1 = tonumber(z1)
  22. while y ~= 0 do
  23. if not turtle.up() then
  24. turtle.digUp()
  25. turtle.up()
  26. y = y+1
  27. else
  28. turtle.up()
  29. y = y+1
  30. end
  31. end
  32. if x > x1 then
  33. Corientation(2)
  34. else
  35. Corientation(0)
  36. end
  37. while x ~= x1 do
  38. if not turtle.forward() then
  39. turtle.dig()
  40. turtle.forward()
  41. x = x+1
  42. else
  43. turtle.forward()
  44. x = x+1
  45. end
  46. if z > z1 then
  47. Corientation(1)
  48. else
  49. Corientation(3)
  50. end
  51. while z ~= z1 do
  52. if not turtle.forward() then
  53. turtle.dig()
  54. turtle.forward()
  55. z = z+1
  56. else
  57. turtle.forward()
  58. z = z+1
  59. end
  60. end
  61. end
  62.  
  63. end
  64. function vidage()
  65. for i=0,x do
  66.  
  67. while true do
  68. print("1")
  69. if orientation ~= 2 then
  70.         turtle.turnLeft()
  71.         orientation = orientation + 1
  72.         else
  73.         break
  74.         end
  75.         end
  76. end
  77. end    
  78.  
  79. deplacement(10,15)
  80. deplacement(0,0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement