Advertisement
KastenN

Untitled

Jul 27th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. print("Digite o X")
  2. x = tonumber(read())
  3.  
  4. print("Digite o Y")
  5. y = tonumber(read())
  6.  
  7. print("Digite o Z")
  8. z = tonumber(read())
  9.  
  10.  
  11. function turnRight()
  12.     turtle.turnRight()
  13.     turtle.dig()
  14.     blockDetect()
  15.     turtle.forward()
  16.     turtle.turnRight()
  17. end
  18.  
  19. function turnLeft()
  20.     turtle.turnLeft()
  21.     turtle.dig()
  22.     blockDetect()
  23.     turtle.forward()
  24.     turtle.turnLeft()
  25. end
  26.  
  27. function turtleDig()
  28.     for i=1,x-1,1 do
  29.         turtle.dig()
  30.             blockDetect()
  31.         turtle.forward()
  32.         putFloor(chao)
  33.     end
  34. end
  35.  
  36. function useTorch()
  37.     turtle.turnRight()
  38.     turtle.turnRight()
  39.     turtle.place()
  40.     turtle.turnRight()
  41.     turtle.turnRight()
  42. end
  43.  
  44. function checkTorch()
  45.     print("Deseja utilizar tochas?")
  46.     print("Se sim-1")
  47.     print("Se nao-0")
  48.     j = tonumber(read())
  49.     if j ~= 0 then
  50.         while turtle.getItemDetail(15) == nil or turtle.getItemDetail(15).name ~= "minecraft:torch" do
  51.             print("Coloca tochas na slot 15")
  52.             read()
  53.         end
  54.         useTorch()
  55.     end
  56. end
  57.  
  58. function goBack()
  59.     if y%2==0 then
  60.         turtle.turnRight()
  61.     else
  62.         for i=1,x,1 do
  63.             turtle.back()
  64.             blockDetect()
  65.         end
  66.         turtle.turnLeft()
  67.     end
  68.     for i=1,y-1,1 do
  69.         turtle.forward()
  70.     end
  71. end
  72.  
  73. function prepareNewLayer(k)
  74.     if k~=z then
  75.         turtle.turnRight()
  76.         turtle.digDown()
  77.         turtle.down()
  78.     end
  79. end
  80.  
  81. function stepsPerLayer()
  82.     steps = x * y + 1
  83.     steps = steps + y-1
  84.     if y%2~=0 then
  85.         steps = steps + x-1
  86.     end
  87.     return steps
  88. end
  89.  
  90. function blockDetect()
  91.     while turtle.detect() == true do
  92.         turtle.dig()
  93.     end
  94. end
  95.  
  96. function refuel()
  97.         turtle.select(16)
  98.         turtle.refuel(math.ceil(math.ceil((stepsPerLayer() * z + 2) / 80)))
  99. end
  100.  
  101. function printFuelNeeded()
  102.     print("E necessario no total " .. math.ceil((stepsPerLayer() * z + 2) / 80) .. " carvoes")
  103. end
  104.  
  105. function requireFuel()
  106.     while turtle.getItemDetail(16) == nil or turtle.getItemDetail(16).name ~= "minecraft:coal" do
  107.         print("Coloca carvao na slot 16")
  108.         print("Ja esta?")
  109.         read()
  110.     end
  111.     while turtle.getItemDetail(16).count < math.ceil((stepsPerLayer() * z + 2) / 80) do
  112.         print("Falta " .. math.ceil((stepsPerLayer() * z + 2) / 80) - turtle.getItemDetail(16).count .. " carvoes" )
  113.         read()
  114.     end
  115.     print("otimo!")
  116. end
  117.  
  118. function createFloor()
  119.         print("Deseja ter chao limpo?")
  120.         print("Se sim-1")
  121.         print("Se nao-0")
  122.         chao = tonumber(read())
  123.         if chao ~= 0 then
  124.         while turtle.getItemDetail(14) == nil or turtle.getItemDetail(14).name ~= "minecraft:water_bucket" do
  125.             print("Coloca um balde de agua na slot 14")
  126.             read()
  127.         end
  128.             while turtle.getItemDetail(13) == nil or turtle.getItemDetail(13).name ~= "minecraft:cobblestone" do
  129.                 print("Coloca cobblestone na slot 13")
  130.                 read()
  131.             end
  132.     end
  133. end
  134.  
  135. function putFloor(chao)
  136.     if chao ~= 0 then
  137.         if turtle.detectDown() ~= true then
  138.       turtle.back()
  139.       turtle.select(14)
  140.       turtle.place()
  141.       turtle.place()
  142.       turtle.forward()
  143.       turtle.select(13)
  144.       turtle.placeDown()
  145.         end
  146.     end
  147. end
  148.  
  149. function main()
  150.     for k=1,z,1 do
  151.         for j=1,y,1 do
  152.         turtleDig()
  153.         if j~=y then
  154.             if j%2~=0 then
  155.                     turnRight()
  156.                 else
  157.                     turnLeft()
  158.             end
  159.         end
  160.     end
  161.     goBack()
  162.     prepareNewLayer(k)
  163.     end
  164. end
  165.  
  166. createFloor()
  167. printFuelNeeded()
  168. requireFuel()
  169. refuel()
  170. turtle.dig()
  171. turtle.forward()
  172. turtle.dig()
  173. turtle.forward()
  174. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement