Advertisement
dunno_plays

HouseBuilding

Jan 16th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.88 KB | None | 0 0
  1. local length = 0
  2. local width = 0
  3. local depth = 0
  4. local gone = 0
  5. local lr = 0
  6. local lengthgone = 0
  7. local chest = turtle.getItemCount(3)
  8.  
  9. local function CheckItems()
  10.          if turtle.getItemCount(16)>0 then -- If slot 16 in turtle has item slot 5 to 16 will go to chest
  11.                         if chest > 0 then
  12.                                 turtle.select(3)
  13.                                 turtle.placeUp()
  14.                                 chest = chest - 1
  15.                                 for slot = 4, 16 do
  16.                                         turtle.select(slot)
  17.                                         turtle.dropUp()
  18.                                         sleep(1.5)
  19.                                 end
  20.                                 turtle.select(4)
  21.                                 print("emptied storage")
  22.                         else
  23.                                 print("turtle run out of chest")
  24.                                 print("press enter after refilling them in slot 3")
  25.                                 input5 = io.read()
  26.                                 chest = turtle.getItemCount(3)
  27.                         end
  28.                 end
  29. end
  30.  
  31. local function DigLength()
  32.     repeat
  33.         while turtle.detect() == true do
  34.             turtle.dig()
  35.         end
  36.         turtle.forward()
  37.         lengthgone = lengthgone+1
  38.  
  39.         CheckItems()
  40.     until lengthgone == length
  41.    
  42.     lengthgone = 0
  43.  
  44.     if lr == 0 then
  45.         lr = 1
  46.     else
  47.         lr = 0
  48.     end
  49. end
  50.  
  51. local function down()
  52.     if turtle.detectDown() == true then turtle.digDown() end
  53.     turtle.turnLeft()
  54.     turtle.turnLeft()
  55.     turtle.down()
  56.     depth = depth-1
  57.     if lr == 0 then
  58.         lr = 1
  59.     else
  60.         lr = 0
  61.     end
  62. end
  63.  
  64. local function Check()
  65.              if turtle.getFuelLevel() == "unlimited" then
  66.                 print("NO NEED FOR FUEL")
  67.              elseif turtle.getFuelLevel() < 1000 then
  68.                 turtle.refuel()
  69.             end
  70. end
  71.  
  72. -- start from here
  73. print("What Length shall the house be?")
  74. input = io.read()
  75. length = tonumber(input)
  76. length = length-1
  77. print("What Width shall the house be?")
  78. input2 = io.read()
  79. width = tonumber(input2)
  80. width = width - 1
  81. print("What Depth shall the house be?")
  82. input3 = io.read()
  83. depth = tonumber(input3)
  84. print("First turn left or right? 0=right, 1=left")
  85. input4 = io.read()
  86. lr = tonumber(input4)
  87. print("place fuel in slots 1 and 2, chests in slot 3")
  88.  
  89. Check()
  90.  
  91. repeat
  92.     DigLength()
  93.     if gone == width then
  94.         if depth > 1 then
  95.         gone = 0
  96.         down()
  97.         print("finished level")
  98.         else
  99.             depth = depth-1
  100.             print("turtle has finished")
  101.         end
  102.     elseif lr == 0 then
  103.         turtle.turnLeft()
  104.         if turtle.detect() == true then turtle.dig() end
  105.         turtle.forward()
  106.         turtle.turnLeft()
  107.         gone = gone+1
  108.     elseif lr == 1 then
  109.         turtle.turnRight()
  110.         if turtle.detect() == true then turtle.dig() end
  111.         turtle.forward()
  112.         turtle.turnRight()
  113.         gone = gone+1
  114.     end
  115. Check()
  116. until depth == 0
  117.  
  118. turtle.turnLeft()
  119. turtle.turnLeft()
  120. length = 0
  121. width = 0
  122. depth = 0
  123. gone = 0
  124. lr = 0
  125. lengthgone = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement