TechManDylan

ChatGPT BuildWall v0.1

Jan 3rd, 2023 (edited)
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.90 KB | None | 0 0
  1. -- This function digs a layer of the wall
  2. function digLayer()
  3.   -- Dig the front row
  4.   turtle.dig()
  5.   turtle.forward()
  6.   turtle.dig()
  7.   turtle.forward()
  8.   turtle.dig()
  9.   turtle.back()
  10.   turtle.back()
  11.   -- Dig the back row
  12.   turtle.dig()
  13.   turtle.back()
  14.   turtle.dig()
  15.   turtle.back()
  16.   turtle.dig()
  17.   turtle.forward()
  18.   turtle.forward()
  19. end
  20.  
  21. -- This function places a layer of blocks
  22. function placeLayer()
  23.   -- Place blocks in the front row
  24.   while not turtle.place() do
  25.     -- If the current slot is empty, check the next slot
  26.     if turtle.getItemCount() == 0 then
  27.       if not turtle.select(turtle.getSelectedSlot() % 16 + 1) then
  28.         -- If there are no more slots, break out of the loop
  29.         break
  30.       end
  31.     end
  32.   end
  33.   turtle.forward()
  34.   while not turtle.place() do
  35.     -- If the current slot is empty, check the next slot
  36.     if turtle.getItemCount() == 0 then
  37.       if not turtle.select(turtle.getSelectedSlot() % 16 + 1) then
  38.         -- If there are no more slots, break out of the loop
  39.         break
  40.       end
  41.     end
  42.   end
  43.   turtle.forward()
  44.   while not turtle.place() do
  45.     -- If the current slot is empty, check the next slot
  46.     if turtle.getItemCount() == 0 then
  47.       if not turtle.select(turtle.getSelectedSlot() % 16 + 1) then
  48.         -- If there are no more slots, break out of the loop
  49.         break
  50.       end
  51.     end
  52.   end
  53.   turtle.back()
  54.   turtle.back()
  55.   -- Place blocks in the back row
  56.   while not turtle.place() do
  57.     -- If the current slot is empty, check the next slot
  58.     if turtle.getItemCount() == 0 then
  59.       if not turtle.select(turtle.getSelectedSlot() % 16 + 1) then
  60.         -- If there are no more slots, break out of the loop
  61.         break
  62.       end
  63.     end
  64.   end
  65.   turtle.back()
  66.   while not turtle.place() do
  67.     -- If the current slot is empty, check the next slot
  68.     if turtle.getItemCount() == 0 then
  69.       if not turtle.select(turtle.getSelectedSlot() % 16 + 1) then
  70.         -- If there are no more slots, break out of the loop
  71.         break
  72.       end
  73.     end
  74.   end
  75.   turtle.back()
  76.   while not turtle.place() do
  77.     -- If the current slot is empty, check the next slot
  78.     if turtle.getItemCount() == 0 then
  79.       if not turtle.select(turtle.getSelectedSlot() % 16 + 1) then
  80.         -- If there are no more slots, break out of the loop
  81.         break
  82.       end
  83.     end
  84.   end
  85.   turtle.forward()
  86.   turtle.forward()
  87. end
  88.  
  89. -- Dig the foundation of the wall
  90. digLayer()
  91. turtle.turnRight()
  92. digLayer()
  93. turtle.turnRight()
  94. digLayer()
  95. turtle.turnRight()
  96. digLayer()
  97.  
  98.  
  99. -- Build the wall
  100. for i=1,3 do
  101.   -- Place the blocks for the layer
  102.   placeLayer()
  103.   turtle.turnRight()
  104.   placeLayer()
  105.   turtle.turnRight()
  106.   placeLayer()
  107.   turtle.turnRight()
  108.   placeLayer()
  109.   -- Move to the next layer
  110.   turtle.up()
  111. end
  112.  
  113. -- Return to the starting position
  114. turtle.turnRight()
  115. turtle.turnRight()
  116. for i=1,3 do
  117.   turtle.down()
  118. end
  119.  
Add Comment
Please, Sign In to add comment