Advertisement
HolOoD

Wall

Feb 16th, 2022
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.82 KB | None | 0 0
  1. function countInventory()
  2. local total = 0
  3.  
  4.     for slot = 1, 16 do
  5.         total = total + turtle.getItemCount(slot)
  6.     end
  7.     return total
  8. end
  9.  
  10. function selectAndPlaceDown()
  11.  
  12.     for slot = 1, 16 do
  13.         if turtle.getItemCount(slot) > 0 then
  14.             turtle.select(slot)
  15.             turtle.placeDown()
  16.             return
  17.         end
  18.     end
  19.  end
  20.  
  21.  
  22. function buildWall(length, height)
  23.     if hare.countInventory() < length * height then
  24.         return false
  25.     end
  26.  
  27.     turtle.up()
  28.  
  29. local movingForward = true
  30.  
  31.     for currentHeight = 1, height do
  32.         for currentLength = 1, length do
  33.             selectAndPlaceDown()
  34.         if movingForward and currentLength ~= length then
  35.             turtle.forward()
  36.         elseif not movingForward and currentLength ~=length then
  37.             turtle.back()
  38.         end
  39.     end
  40.         if currentHeight ~= height then
  41.             turtle.up()
  42.         end
  43.     movingForward = not movingForward
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement