Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. local rob = require("robot")
  2. local shell = require("shell")
  3. local component = require("component")
  4. local term = require("term")
  5.  
  6. local g = component.generator
  7. local c = component.computer
  8.  
  9. term.clear()
  10.  
  11. term.write("Entrez la longueur : ")
  12. local longueur = term.read()
  13.  
  14. term.clear()
  15.  
  16. term.write("Entrez la largeur (multiple de 2): ")
  17. local largeur = term.read()
  18.  
  19. while(largeur % 2 ~= 0) do
  20. term.clear()
  21. term.write("Entrez la largeur (multiple de 2): ")
  22. largeur = term.read()
  23. end
  24.  
  25. local item = component.inventory_controller.getStackInInternalSlot(1)
  26.  
  27. if item then
  28. if(item.name ~='minecraft:coal' and item.name ~= 'minecraft:coal_block') then
  29. term.clear()
  30. term.write("Attention : Aucun carburant dans la première case de l'inventaire.")
  31. end
  32. else
  33. term.clear()
  34. term.write("Attention : Aucun carburant dans la première case de l'inventaire.")
  35. end
  36.  
  37. os.sleep(2)
  38. term.clear()
  39. term.write("Le robot va maintenant démarrer...")
  40.  
  41. for i=1, 5 do
  42.  
  43. c.beep(1800, 0.2)
  44.  
  45. end
  46.  
  47.  
  48.  
  49. --refueler si nécessaire
  50. function refuel()
  51. if(g.count() <1) then
  52. rob.select(1)
  53. g.insert(1)
  54. end
  55. end
  56.  
  57.  
  58. for i=1, largeur / 2 do
  59.  
  60. refuel()
  61. rob.swing()
  62. rob.forward()
  63.  
  64. for i=1, longueur - 1 do
  65.  
  66. rob.swingUp()
  67. rob.swingDown()
  68. rob.swing()
  69. rob.forward()
  70.  
  71. end
  72.  
  73. rob.swingUp()
  74. rob.swingDown()
  75.  
  76.  
  77. rob.turnRight()
  78. rob.swing()
  79. rob.forward()
  80. rob.turnRight()
  81. rob.swingUp()
  82. rob.swingDown()
  83. rob.turnRight()
  84.  
  85. rob.swing()
  86. rob.forward()
  87.  
  88. for i=1, longueur - 1 do
  89.  
  90. refuel()
  91. rob.swingUp()
  92. rob.swingDown()
  93. rob.swing()
  94. rob.forward()
  95.  
  96. end
  97.  
  98. rob.turnLeft()
  99. rob.forward()
  100. rob.turnLeft()
  101.  
  102. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement