Advertisement
someone3709

Ai made this code 2

Jan 4th, 2023 (edited)
1,048
0
Never
3
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.70 KB | Gaming | 0 0
  1. -- Prompt the user to enter the length of the bridge
  2. print("Enter the length of the bridge:")
  3. length = tonumber(read())
  4.  
  5. -- Check if the length is valid
  6. if length <= 0 then
  7.   print("Error: Invalid length.")
  8.   return
  9. end
  10.  
  11. -- Place the first block of the bridge
  12. turtle.placeDown()
  13.  
  14. -- Build the rest of the bridge
  15. for i=2,length do
  16.   if not turtle.placeDown() then
  17.     -- Find the next slot with blocks
  18.     for j=2,16 do
  19.       turtle.select(j)
  20.       if turtle.getItemCount() > 0 then
  21.         turtle.placeDown()
  22.         break
  23.       end
  24.     end
  25.   end
  26.   turtle.forward()
  27. end
  28.  
  29. -- Return to the starting position
  30. turtle.turnRight()
  31. turtle.turnRight()
  32. for i=2,length do
  33.   turtle.forward()
  34. end
  35.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement