Advertisement
Lukyrouge22

Untitled

Nov 6th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. function start()
  2. write("Longueur ?")
  3. longueur = read()
  4. longueurs = tonumber(longueur)
  5. if longueurs >= 4 then
  6. write("Combien de chemin ?")
  7. chemin = read()
  8. chemins = tonumber(chemin)
  9. if chemins >= 1 then
  10. write("Quel est le slot du charbon ?")
  11. coal_slot = read()
  12. coal_slot = tonumber(coal_slot)
  13. write("Nous allons faire : " .. chemin .. " chemins de " .. longueur .. " longueur.")
  14. coal()
  15. end
  16. else
  17. write("Cela doit รชtre un nombre plus grand que 3")
  18. end
  19. end
  20.  
  21. function coal()
  22.  
  23. moves = longueurs * chemins + 3 * chemins
  24. active_coal = turtle.getFuelLevel()
  25. active_coal = tonumber(active_coal)
  26. if moves > active_coal then
  27. coal = moves - active_coal
  28. coal = coal / 80
  29. coal = math.ceil(coal)
  30. write("Active coal : " .. active_coal .. " moves : " .. moves .. " coal: " .. coal .. " slot : " .. coal_slot .. " count : " .. turtle.getItemCount(coal_slot))
  31. if turtle.getItemCount(coal_slot) >= coal then
  32. turtle.select(coal_slot)
  33. turtle.refuel(coal)
  34. mine()
  35. else
  36. write("Veuillez insรฉrer " + coal + " charbons dans le slot " + coal_slot)
  37. os.sleep(6)
  38. coal()
  39. end
  40. else
  41. mine()
  42. end
  43. end
  44.  
  45. function deposing()
  46. turtle.dig()
  47. turtle.select(1)
  48. turtle.place()
  49. for i = 2,16 do
  50. turtle.select(i)
  51. turtle.drop()
  52. end
  53. turtle.select(1)
  54. turtle.dig()
  55. end
  56.  
  57. function mine()
  58. blocks = 0
  59. for i = 1, chemin do
  60. for c = 1, longueur do
  61. graphic()
  62. if turtle.getItemCount(16) == 0 then
  63. turtle.dig()
  64. blocks++
  65. turtle.forward()
  66. turtle.digUp()
  67. blocks++
  68. else
  69. deposing()
  70. end
  71. end
  72. if (i%2 == 0) then
  73. turtle.turnRight()
  74. turtle.dig()
  75. blocks++
  76. turtle.forward()
  77. turtle.digUp()
  78. blocks++
  79. turtle.dig()
  80. blocks++
  81. turtle.forward()
  82. turtle.digUp()
  83. blocks++
  84. turtle.dig()
  85. blocks++
  86. turtle.forward()
  87. turtle.digUp()
  88. blocks++
  89. turtle.turnRight()
  90. else
  91. turtle.turnLeft()
  92. turtle.dig()
  93. blocks++
  94. turtle.forward()
  95. turtle.digUp()
  96. blocks++
  97. turtle.dig()
  98. blocks++
  99. turtle.forward()
  100. turtle.digUp()
  101. blocks++
  102. turtle.dig()
  103. blocks++
  104. turtle.forward()
  105. turtle.digUp()
  106. blocks++
  107. turtle.turnLeft()
  108. end
  109. end
  110. end
  111. function graphic()
  112. term.setBackgroundColor(colours.black)
  113. term.clear()
  114. term.setCursorPos(1,1)
  115. print("Il reste " .. moves .. " mouvements")
  116. print("Il reste " .. turtle.getFuelLevel().. " de fuel")
  117. print(blocks .. "on deja ete mines")
  118. end
  119. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement