Advertisement
Ml_Edwins

SalleCreator

Oct 25th, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.25 KB | None | 0 0
  1. --http/pastebin get c7ZSrQxK Salle
  2. -- By ML Edwins copyright ML Team
  3. local TurtlePos = {x=nil,y=nil,z=nil}
  4. local SalleTaille = {x=nil,y=nil,z=nil, total=nil}
  5.  
  6. function dig()
  7.     while turtle.detect() do
  8.         turtle.dig()
  9.         os.sleep(0.5)
  10.     end
  11. end
  12. function StartDig()
  13.     for p = 1, Salle.y, 1 do
  14.         for i = 1, SalleTaille.z, 1 do
  15.             for o = 2, SalleTaille.x, 1 do
  16.                 dig()
  17.                 turtle.forward()
  18.             end
  19.             if i == SalleTaille.z then
  20.                 if turtle.detectUp() then turtle.digUp() end
  21.                 turtle.up()
  22.                 turtle.turnLeft()
  23.             elseif i % 2 == 0 then
  24.                 turtle.turnRight()
  25.                 dig()
  26.                 turtle.forward()
  27.                 turtle.turnRight()
  28.             else
  29.                 turtle.turnLeft()
  30.                 dig()
  31.                 turtle.forward()
  32.                 turtle.turnLeft()
  33.             end
  34.         end
  35.     end
  36. end
  37. function ClaimCoal(CharbonNeeded)
  38.     --write("Requete au serveur en cours...")
  39.     --print("Error")
  40.     --print("Serveur indisponible, veuillez ajouter le charbon manuellement")
  41.     while turtle.getFuelLevel() < SalleTaille.total do
  42.         local nbCharbon
  43.         for i = 1, 16, 1 do
  44.             nbCharbon = math.ceil((SalleTaille.total - turtle.getFuelLevel()) / 64)
  45.             term.setCursorPos(1,6)
  46.             if nbCharbon <= 0 then
  47.                 write("En attente de 0 Charbon...")
  48.                 break
  49.             end
  50.             write("En attente de "..nbCharbon.." Charbon...")
  51.             turtle.select(i)
  52.             turtle.refuel(nbCharbon)
  53.            
  54.         end
  55.         if nbCharbon > 0 then os.sleep(10) end
  56.     end
  57.     print("Ok")
  58.     os.sleep(1)
  59. end
  60.  
  61. function CheckIfPossibleToBuild()
  62.     SalleTaille.total = SalleTaille.x * SalleTaille.y * SalleTaille.z
  63.     print("Vous allez extraire : "..SalleTaille.total.." cube")
  64.     write("Verification des stocks...")
  65.     if SalleTaille.total > turtle.getFuelLevel() then
  66.         print("Error")
  67.         local CharbonNeeded = math.ceil((SalleTaille.total - turtle.getFuelLevel()) / 64)
  68.         ClaimCoal(CharbonNeeded)
  69.     else
  70.     print("Ok")
  71.     end
  72. end
  73.  
  74. function BuildSalleCubiqueTaille()
  75.     term.clear()
  76.     term.setCursorPos(1,1)
  77.     print("Indiquez la longueur (x):")
  78.     SalleTaille.x = read()
  79.     term.clear()
  80.     term.setCursorPos(1,1)
  81.     print("Indiquez la hauteur (y):")
  82.     SalleTaille.y = read()
  83.     term.clear()
  84.     term.setCursorPos(1,1)
  85.     print("Indiquez la largeur (z):")
  86.     SalleTaille.z = read()
  87.     term.clear()
  88.     term.setCursorPos(1,1)
  89.     CheckIfPossibleToBuild()
  90.     StartDig()
  91. end
  92.  
  93. BuildSalleCubiqueTaille()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement