ade_talon

16x16 Platform

Sep 30th, 2024
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.50 KB | Gaming | 0 0
  1. -- Function to select a random slot between 1 and 4
  2. function selectRandomBlock()
  3.     turtle.select(math.random(1, 4))
  4. end
  5.  
  6. -- Function to place a block and move forward
  7. function placeBlockAndMove()
  8.     selectRandomBlock()  -- Select a random block from slots 1-4
  9.     turtle.placeDown()   -- Place the block below the turtle
  10.     turtle.forward()     -- Move the turtle forward
  11. end
  12.  
  13. -- Function to move to the next row (zigzag pattern)
  14. function moveToNextRow(direction)
  15.     if direction == "right" then
  16.         turtle.turnRight()
  17.         turtle.forward()
  18.         turtle.turnRight()
  19.     else
  20.         turtle.turnLeft()
  21.         turtle.forward()
  22.         turtle.turnLeft()
  23.     end
  24. end
  25.  
  26. -- Main function to build the platform
  27. function buildPlatform()
  28.     local direction = "right" -- Start moving to the right
  29.  
  30.     for row = 1, 16 do
  31.         -- Place blocks in a row
  32.         for col = 1, 16 do
  33.             placeBlockAndMove()
  34.         end
  35.  
  36.         -- Move to the next row if not on the last row
  37.         if row < 16 then
  38.             moveToNextRow(direction)
  39.  
  40.             -- Toggle the direction for the next row
  41.             if direction == "right" then
  42.                 direction = "left"
  43.             else
  44.                 direction = "right"
  45.             end
  46.         end
  47.     end
  48. end
  49.  
  50. -- Make sure the turtle starts at the correct position
  51. turtle.forward()  -- Move the turtle into starting position
  52.  
  53. -- Run the platform building function
  54. buildPlatform()
  55.  
  56. print("16x16 platform complete!")
  57.  
Add Comment
Please, Sign In to add comment