Advertisement
JMANN2400

OceanTempleWall[NoFuel]

Aug 26th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.24 KB | None | 0 0
  1.  
  2.  
  3.  
  4. x = 0
  5.  
  6. y = 0
  7.  
  8. z = 0
  9.  
  10. totalBlocks = 0
  11.  
  12. facing = "north"
  13.  
  14. slot = 1
  15.  
  16. xmem = 0
  17.  
  18. ymem = 0
  19.  
  20. zmem = 0
  21.  
  22. facingmem = "north"
  23.  
  24. print("Length = ?")
  25.  
  26. l = tonumber(read())
  27.  
  28. print("Width = ?")
  29.  
  30. w = tonumber(read())
  31.  
  32. print("Height = ?")
  33.  
  34. h = tonumber(read())
  35.  
  36. function turn(direction)
  37.     if direction == "north" then
  38.         if facing == "west" then
  39.             turtle.turnRight()
  40.         end
  41.         if facing == "south" then
  42.             turtle.turnRight()
  43.             turtle.turnRight()
  44.         end
  45.         if facing == "east" then
  46.             turtle.turnLeft()
  47.         end
  48.         facing = "north"
  49.     end
  50.     if direction == "west" then
  51.         if facing == "south" then
  52.             turtle.turnRight()
  53.         end
  54.         if facing == "east" then
  55.             turtle.turnRight()
  56.             turtle.turnRight()
  57.         end
  58.         if facing == "north" then
  59.             turtle.turnLeft()
  60.         end
  61.         facing = "west"
  62.     end
  63.     if direction == "south" then
  64.         if facing == "east" then
  65.             turtle.turnRight()
  66.         end
  67.         if facing == "north" then
  68.             turtle.turnRight()
  69.             turtle.turnRight()
  70.         end
  71.         if facing == "west" then
  72.             turtle.turnLeft()
  73.         end
  74.         facing = "south"
  75.     end
  76.     if direction == "east" then
  77.         if facing == "north" then
  78.             turtle.turnRight()
  79.         end
  80.         if facing == "west" then
  81.             turtle.turnRight()
  82.             turtle.turnRight()
  83.         end
  84.         if facing == "south" then
  85.             turtle.turnLeft()
  86.         end
  87.         facing = "east"
  88.     end
  89. end
  90.  
  91. function returnHome()
  92.     xmem = x
  93.     ymem = y
  94.     zmem = z
  95.     facingmem = facing
  96.     while z < h + 1 do
  97.         if turtle.up() then
  98.             z = z + 1
  99.         end
  100.     end
  101.     turn("west")
  102.     while x > 0 do
  103.         if turtle.forward() then
  104.             x = x - 1
  105.         end
  106.     end
  107.     turn("south")
  108.     while y > -1 do
  109.         if turtle.forward() then
  110.             y = y - 1
  111.         end
  112.     end
  113.     turn("north")
  114.     while z > 0 do
  115.         if turtle.down() then
  116.             z = z - 1
  117.         end
  118.     end
  119. end
  120.  
  121. function resume()
  122.     while z < h + 1 do
  123.         if turtle.up() then
  124.             z = z + 1
  125.         end
  126.     end
  127.     while y < ymem do
  128.         if turtle.forward() then
  129.             y = y + 1
  130.         end
  131.     end
  132.     turn("east")
  133.     while x < xmem do
  134.         if turtle.forward() then
  135.             x = x + 1
  136.         end
  137.     end
  138.     turn(facingmem)
  139.     while z > zmem do
  140.         if turtle.down() then
  141.             z = z - 1
  142.         end
  143.     end
  144. end
  145.  
  146. function refill()
  147.     returnHome()
  148.     for i = 1,16,1 do
  149.         turtle.suckDown()
  150.     end
  151.     resume()
  152. end
  153.  
  154. function countBlocks()
  155.     totalBlocks = 0
  156.     for i = 1,16,1 do
  157.         totalBlocks = totalBlocks + turtle.getItemCount(i)
  158.     end
  159. end
  160.  
  161. function checkForRefill()
  162.     countBlocks()
  163.     if totalBlocks < h then
  164.         refill()
  165.     end
  166. end
  167.  
  168. function selectSlot()
  169.     if turtle.getItemCount(slot) == 0 and slot < 16 then
  170.         slot = slot + 1
  171.     elseif turtle.getItemCount(slot) == 0 and slot == 16 then
  172.         slot = 1
  173.     end
  174.     turtle.select(slot)
  175. end
  176.  
  177. function pillar()
  178.     checkForRefill()
  179.     while z < h do
  180.         if turtle.up() then
  181.             z = z + 1
  182.         end
  183.         selectSlot()
  184.         turtle.placeDown()
  185.     end
  186.     if x == 0 and y == 0 then
  187.         turn("north")
  188.     end
  189.     if x == 0 and y == l - 1 then
  190.         turn("east")
  191.     end
  192.     if x == w - 1 and y == 0 then
  193.         turn("west")
  194.     end
  195.     if x == w - 1 and y == l - 1 then
  196.         turn("south")
  197.     end
  198.     if turtle.forward() then
  199.         if facing == "north" then
  200.             y = y + 1
  201.         end
  202.         if facing == "west" then
  203.             x = x - 1
  204.         end
  205.         if facing == "south" then
  206.             y = y - 1
  207.         end
  208.         if facing == "east" then
  209.             x = x + 1
  210.         end
  211.     end
  212.     while z > 0 do
  213.         if turtle.down() then
  214.             z = z - 1
  215.         end
  216.     end
  217. end
  218.  
  219. while true do
  220.     pillar()
  221. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement