Advertisement
Gioves

[ComputerCraft]DustBreaker

Oct 18th, 2014
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.41 KB | None | 0 0
  1. --Gioves vBeta 0.2
  2.  
  3. local enderChestSlot = 16
  4. local coalChestSlot = 15
  5. local coalEmplacement = 14
  6. local firstSlot = 1
  7. local lastSlot = 4
  8.  
  9. local i=0 -- var for loop
  10.  
  11. function emptyIfFull(fin) --check if the turtle is full and empty it
  12.     if (turtle.getItemCount(lastSlot) > 0) or (fin == true) then
  13.         print("Vidange des items...")
  14.         while not turtle.up() do
  15.                 turtle.digUp()
  16.         end
  17.         turtle.down()
  18.         turtle.select(enderChestSlot)
  19.         turtle.placeUp()
  20.         for slot=firstSlot,lastSlot do
  21.             turtle.select(slot)
  22.             while turtle.getItemCount(slot) > 0 do
  23.                 turtle.dropUp(turtle.getItemCount(slot))
  24.                 if turtle.getItemCount(slot) > 0 then
  25.                     sleep(1)
  26.                 end
  27.             end
  28.         end
  29.         print("Fin")
  30.         turtle.select(enderChestSlot)
  31.         turtle.digUp()
  32.     end
  33. end
  34.  
  35. function fillCoal() --fill the fuel of the turtle
  36.     if turtle.getFuelLevel()<160 then
  37.         print("Remplissage de Coal...")
  38.         while not turtle.up() do
  39.                 turtle.digUp()
  40.                 sleep(0.10)
  41.         end
  42.         turtle.select(coalChestSlot)
  43.         turtle.down()
  44.         turtle.placeUp()
  45.         turtle.select(coalEmplacement)
  46.         turtle.suckUp(4)
  47.         turtle.refuel(4)
  48.         print("Fin")
  49.         turtle.select(coalChestSlot)
  50.         turtle.digUp()
  51.     end
  52. end
  53.  
  54. --Main program
  55. local length = 0
  56. local width = 0
  57. local i = 1
  58. local j = 2
  59. local leftright = false --turn left right/left at the end of the path
  60.  
  61.  
  62. print("Bibiche la depopeuse de dune v0.2 Beta.")
  63. print("Info : longueur face a la turtle, largeur vers la droite. Placez l'enderchest a coal dans le slot 15. Placez l'enderchest a minerais dans le slot 16.Renvoie tout les deux stacks environ.")
  64. print("Donnez la longueur a creuser :")
  65. length = tonumber(read())-1
  66. print("Donnez la largeur a creuser :")
  67. width = tonumber(read())
  68. print("Sable previsionnel :")
  69. print(length*width*4)
  70. print("En cour...")
  71.  
  72. if (length<=0) or (width<=0) then
  73.     print("Erreur sur la taille donnee !")
  74. else
  75.     for i=1,width do
  76.         for j=1,length do
  77.             while not turtle.forward() do
  78.                 turtle.dig()
  79.             end
  80.             fillCoal()
  81.             emptyIfFull()
  82.         end
  83.         if(leftright==false) and (i~=width) then
  84.             turtle.turnRight()
  85.             while not turtle.forward() do
  86.                 turtle.dig()
  87.             end
  88.             turtle.turnRight()
  89.             leftright = true
  90.         elseif(leftright == true) and (i~=width) then
  91.             turtle.turnLeft()
  92.             while not turtle.forward() do
  93.                 turtle.dig()
  94.             end
  95.             turtle.turnLeft()
  96.             leftright=false
  97.         end
  98.     end
  99.     emptyIfFull(true)
  100.     print("Travail termine : sable envoye dans l'enderchest")
  101. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement