Advertisement
someone3709

ggsgsgsgsgssgsgsgsggssggssggssg

Jun 22nd, 2023
799
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.18 KB | None | 0 0
  1. -- Function to check if the turtle has enough fuel
  2. function checkFuel(level)
  3.   if turtle.getFuelLevel() < level then
  4.     print("Not enough fuel. Please refuel the turtle.")
  5.     return false
  6.   end
  7.   return true
  8. end
  9.  
  10. -- Function to build a platform of the specified size
  11. function buildPlatform(size)
  12.   -- Check if the turtle has enough fuel
  13.   if not checkFuel((size * 2) + 1) then
  14.     return
  15.   end
  16.  
  17.   -- Build the platform
  18.   for i = 1, size do
  19.     turtle.forward()
  20.     for j = 1, size - 1 do
  21.       turtle.placeDown()
  22.       turtle.forward()
  23.     end
  24.     turtle.placeDown()
  25.     if i < size then
  26.       if i % 2 == 0 then
  27.         turtle.turnRight()
  28.         turtle.forward()
  29.         turtle.turnRight()
  30.       else
  31.         turtle.turnLeft()
  32.         turtle.forward()
  33.         turtle.turnLeft()
  34.       end
  35.     end
  36.   end
  37.  
  38.   -- Return to the starting position
  39.   turtle.turnRight()
  40.   turtle.turnRight()
  41.   for i = 1, size - 1 do
  42.     turtle.forward()
  43.   end
  44.   turtle.turnRight()
  45. end
  46.  
  47. -- Prompt the user for the platform size
  48. print("Enter the size of the platform:")
  49. local size = tonumber(read())
  50.  
  51. -- Call the buildPlatform function with the provided size
  52. buildPlatform(size)
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement