Keledan

Untitled

Jul 21st, 2015
557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.29 KB | None | 0 0
  1. -- original script by matdombrock/pyramid.lua
  2.  
  3. b = 0 --bricks laid
  4. w = 0 --wall number
  5. h = 5 --height of the structure in layers
  6. i = 0 --current number layers
  7. x = 9--how wide the base should be
  8. n = 1 --selection number for inv
  9.  
  10. function start()
  11.     turtle.up()
  12. end
  13. function sel()
  14.     if turtle.getItemCount(n) <1 then--check to see if we are out of material
  15.         n = n+1
  16.     end
  17.     if n > 16 then --if we are done the last item slot
  18.         n = 1 --switch back to slot one
  19.         while turtle.getItemCount(1) <1 do --if there is nothing in slot one ask user to refill
  20.             print ('please reload, by filling slot one last')
  21.             sleep(1)
  22.         end
  23.     end
  24.     turtle.select(n)--change slot
  25. end
  26.  
  27.  
  28.  
  29.  
  30. function buildlayer()
  31.     if w == 0 then
  32.         x = x -1
  33.     end
  34.     while w < 4 do --while we have not built 4 walls yet
  35.         while b < x do
  36.  
  37.             sel()
  38.             turtle.digDown()
  39.             turtle.placeDown()
  40.             turtle.forward()--build the wall
  41.             b = b + 1
  42.         end
  43.         while b == x do
  44.             turtle.turnLeft()--turn so we can build the next wall
  45.             w = w+1
  46.             b = 0
  47.         end
  48.         if w == 3 then
  49.             x = x-1
  50.         end
  51.     end
  52.    
  53.     while w == 4 do
  54.         turtle.placeDown()
  55.         turtle.up()--move up so we can start another layer
  56.        
  57.         turtle.forward()
  58.         w = 0
  59.     end
  60. end
  61. start()
  62. while i < h do--while we have not reached our intended height
  63.     buildlayer()
  64.     i = i+1
  65. end
Advertisement
Add Comment
Please, Sign In to add comment