celestialgod

computercraft build wall

May 19th, 2016
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1. term.write("Please enter the height of wall: ")
  2. local h = tonumber(read())
  3. term.write("Please enter the width of wall: ")
  4. local w = tonumber(read())
  5.  
  6. local itemID = 1
  7. for i = 1, w do
  8.   for j = 1, h+1 do
  9.     turtle.select(itemID)
  10.     while (turtle.getItemCount() == 0) do
  11.       itemID = itemID + 1
  12.       if (itemID > 16) then
  13.         break
  14.       end
  15.       turtle.select(itemID)
  16.     end
  17.    
  18.     if (itemID > 16) then
  19.       break
  20.     end
  21.    
  22.     if (j == h+1 and i % 2 == 1) then
  23.       turtle.up()
  24.       turtle.place()
  25.       turtle.down()
  26.       turtle.placeUp()
  27.       break
  28.     elseif (j == 1 and i % 2 == 0) then
  29.       turtle.up()
  30.       turtle.place()
  31.       turtle.down()
  32.       turtle.placeUp()
  33.     elseif (j == h+1 and i % 2 == 0) then
  34.       break
  35.     end
  36.    
  37.     if (i % 2 == 1) then
  38.       turtle.place()
  39.       if (j < h) then
  40.         turtle.up()
  41.       end
  42.     else
  43.       turtle.place()
  44.       if (j < h) then
  45.         turtle.down()
  46.       end
  47.     end
  48.   end
  49.  
  50.   if (itemID > 16) then
  51.     break
  52.   end
  53.  
  54.   if (i == w) then
  55.     while (not turtle.detectDown()) do
  56.       turtle.down()
  57.     end
  58.     break
  59.   end
  60.   turtle.turnRight()
  61.   turtle.forward()
  62.   turtle.turnLeft()
  63. end
Advertisement
Add Comment
Please, Sign In to add comment