aynoblo

SuperMiner

Apr 7th, 2020
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.95 KB | None | 0 0
  1. --https://pastebin.com/LkvtrNdR
  2. --pastebin run LkvtrNdR SuperMineur
  3.  
  4. local nbFrontBloc=0
  5. local posFrontBloc=0
  6.  
  7. local nbUpBloc=0
  8. local posUpBloc=0
  9. local toGround=false
  10. local countGoGround=""
  11.  
  12. local nbRightBloc=0
  13. local posRightBloc=0
  14. local pairRight=0
  15. local side=1 --1 = turn to right 2= turn to left
  16.  
  17. local consommable=""
  18.  
  19. local input
  20.  
  21. --Saisi du Nombre
  22. function saisieNombre()
  23.         term.setCursorPos(1,9)
  24.         input=read()
  25.         input=tonumber(input)
  26.         while type(input)==nil and input>=0 and input<=128 do
  27.                 term.setCursorPos(1,8)
  28.                 print("Nombre incorrect, recommencez.")
  29.                 term.setCursorPos(1,9)
  30.                 input=read()
  31.                 input=tonumber(input)
  32.         end
  33.         return input
  34. end
  35.  
  36. --Fonction de minage
  37. function mining()
  38.         while turtle.detectDown() do
  39.                 turtle.digDown()
  40.         end
  41.         while turtle.detectUp() do
  42.                 turtle.digUp()
  43.         end
  44.         while turtle.detect() do
  45.                 turtle.dig()
  46.         end
  47.         turtle.forward()
  48. end
  49.  
  50. function sortItems()
  51.         local itemName=""
  52.         for i=1,16 do
  53.                 turtle.select(i)
  54.                 if turtle.getItemDetail()~=nil then
  55.                         itemName=turtle.getItemDetail().name
  56.                         if itemName~="minecraft:coal" and itemName~="minecraft:iron_ore" and itemName~="minecraft:redstone" and itemName~="minecraft:lapis_lazuli" and itemName~="minecraft:diamond" and itemName~="minecraft:emerald" then
  57.                                 turtle.dropDown()
  58.                         end
  59.                 end
  60.         end
  61.         turtle.select(1)
  62. end
  63.  
  64. term.clear()
  65. term.setCursorPos(1,1)
  66. print("Assurez vous que la turtle est placée au bloc le plus bas, le plus à gauche de votre session de minage.")
  67. term.setCursorPos(1,6)
  68. print("Combien voulez vous de blocs en face de la turtle?     ")
  69. nbFrontBloc=saisieNombre()-1
  70. term.setCursorPos(1,8)
  71. print("          ")
  72. term.setCursorPos(1,6)
  73. print("Combien voulez vous de blocs à droite de la turtle?    ")
  74. print("")
  75. nbRightBloc=saisieNombre()
  76. term.setCursorPos(1,8)
  77. print("          ")
  78. if nbRightBloc%2==0 then
  79.         pairRight=1
  80. else
  81.         pairRight=0
  82. end
  83. term.setCursorPos(1,6)
  84. print("Combien voulez vous de blocs au dessus de la turtle? (x3), (0= jusqu'au sol)")
  85. nbUpBloc=saisieNombre()
  86. term.setCursorPos(1,8)
  87. print("          ")
  88. if nbUpBloc==0 then
  89.         nbUpBloc=85
  90.         toGround=true
  91.         countGoGround=0
  92. end
  93.  
  94. consommable = (nbRightBloc * nbFrontBloc*(nbUpBloc*3))
  95.  
  96. while consommable - turtle.getFuelLevel()>0 do
  97.         local remain = consommable - turtle.getFuelLevel()
  98.         print("Veuillez placer",(math.ceil(remain/80)),"Coal OU",(math.ceil(remain/1000)),"sceau de lave")
  99.         detect=read()
  100.         if turtle.getItemCount(1)>0 then
  101.                 turtle.refuel(turtle.getItemCount(1))
  102.         end
  103.         if toGround==true then
  104.                 consommable=-999999
  105.         end
  106. end
  107.  
  108.  
  109. term.clear()
  110. term.setCursorPos(1,1)
  111. term.setTextColor(colors.yellow)
  112. print("In mining...    ")
  113.  
  114. turtle.digUp()
  115. turtle.up()
  116. turtle.digUp()
  117.  
  118. --Y
  119. while posUpBloc<nbUpBloc do
  120.         --Z
  121.         while posRightBloc<nbRightBloc do
  122.                 --X
  123.                 while posFrontBloc<nbFrontBloc do
  124.                         mining()
  125.                         posFrontBloc=posFrontBloc+1
  126.                 end
  127.                 posRightBloc=posRightBloc+1
  128.                 posFrontBloc=0
  129.                 if side==1 then
  130.                         side=2
  131.                         turtle.turnRight()
  132.                         mining()
  133.                         turtle.turnRight()
  134.                 elseif side==2 then
  135.                         side=1
  136.                         turtle.turnLeft()
  137.                         mining()
  138.                         turtle.turnLeft()
  139.                 end
  140.                 sortItems()
  141.                 -----------------------------
  142.         end
  143.         posUpBloc=posUpBloc+1
  144.         posRightBloc=0
  145.         posFrontBloc=0
  146.         if pairRight==1 then
  147.                 turtle.turnLeft()
  148.  
  149.                 for i=1,nbRightBloc do
  150.                         turtle.forward()
  151.                 end
  152.                 turtle.turnRight()
  153.         else
  154.                 turtle.turnRight()
  155.                 for i=1,nbRightBloc do
  156.                         turtle.forward()
  157.                 end
  158.                 turtle.turnLeft()
  159.                 for i=1,nbFrontBloc do
  160.                         turtle.forward()
  161.                 end
  162.                 turtle.turnRight()
  163.                 turtle.turnRight()
  164.         end
  165.         side=1
  166.         if posUpBloc<nbUpBloc then
  167.                 turtle.up()
  168.                 turtle.digUp()
  169.                 turtle.up()
  170.                 turtle.digUp()
  171.                 turtle.up()
  172.                 turtle.digUp()
  173.         end
  174. end
  175.  
  176. for i=1,nbUpBloc*3 do
  177.     turtle.down()
  178. end
  179.  
  180. term.setCursorPos(1,1)
  181. print("Mining finished.       ")
Advertisement
Add Comment
Please, Sign In to add comment