Advertisement
Olena_Kuznietsova

first house

Dec 27th, 2024
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function line(dlina,from)
  2.     for x = 1 , dlina do
  3.         if turtle.getItemCount() == 0 then
  4.             turtle.select(2)
  5.         end
  6.         turtle.turnRight()
  7.         searchBlock(from)
  8.         turtle.placeDown()
  9.         turtle.turnLeft()
  10.         turtle.forward()
  11.     end
  12. end
  13. function square(dlina,from)
  14.     for b = 1, 4 do
  15.         line(dlina,from)
  16.         turtle.turnRight()
  17.     end
  18. end
  19. function cube(length,height,from)
  20.     for s = 1 , height do
  21.         square(length,from)
  22.         turtle.up()
  23.        
  24.     end
  25. end
  26.  
  27. function pyramid(size,from)
  28.     squareSize = size
  29.     squareNum = math.ceil(size / 2)
  30.     for y = 1, squareNum do
  31.         square(squareSize,from)
  32.         turtle.forward()
  33.         turtle.turnRight()
  34.         turtle.up()
  35.         turtle.forward()
  36.         turtle.turnLeft()
  37.         squareSize = squareSize - 2
  38.     end
  39. end
  40. function roof(size)
  41.     pyramid(size, 5)
  42.     half = math.ceil(size / 2)
  43.     for i = 1, half do
  44.         turtle.back()
  45.     end
  46.     turtle.turnLeft()
  47.     for i = 1, half do
  48.         turtle.forward()
  49.     end
  50.     turtle.turnRight()
  51.     for i = 1, half - 1 do
  52.         turtle.down()
  53.     end
  54.     pyramid(size, 9)
  55. end
  56.  
  57. function searchBlock(from)
  58.     current = from
  59.     turtle.select(current)
  60.     while turtle.getItemCount() == 0 do
  61.         current = current + 1
  62.         turtle.select(current)
  63.     end
  64.    
  65. end
  66. function house(lenght, height)
  67.     cube(lenght,height, 1)
  68.     roof(lenght)
  69. end
  70.    
  71. -- PROGRAM
  72. house(7, 3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement