Advertisement
CelticCoder

fillBlock

Jan 23rd, 2024 (edited)
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.30 KB | None | 0 0
  1. os.loadAPI("buildSupport.lua")
  2. os.loadAPI("userInput.lua")
  3.  
  4.  
  5. -- make the turtle go down until it can't
  6. function goDown()
  7.     local blocksDown = 0
  8.     while turtle.down() do
  9.         blocksDown = blocksDown + 1
  10.     end
  11.     return blocksDown
  12. end
  13.  
  14. -- make the turtle go up a certain number of blocks
  15. function goUp(blocks)
  16.     for i = 1, blocks do
  17.         turtle.up()
  18.         buildSupport.placeDown()
  19.     end
  20. end
  21.  
  22. function fillY()
  23.     local blocksDown = goDown()
  24.     goUp(blocksDown)
  25. end
  26.  
  27. width = tonumber(userInput.getUserInput("Please Enter a Length: "))
  28. length = tonumber(userInput.getUserInput("Please Enter a Width: "))
  29.  
  30. print("Fuel And Blocks Cannot be Predicted")
  31. print("Fuel")
  32. print("currently: " .. turtle.getFuelLevel() .. " out of " .. turtle.getFuelLimit())
  33. print("or " .. (turtle.getFuelLevel()/turtle.getFuelLimit()) * 100 .. "%")
  34.  
  35. userInput.getUserInput("Press anything to continue: ")
  36.  
  37. turtle.forward()
  38. for i = 1, length do
  39.     for j = 1, width do
  40.         fillY()
  41.         if j < width then
  42.             turtle.forward()
  43.         end
  44.     end
  45.     if i < length then
  46.         if i % 2 == 0 then
  47.             turtle.turnLeft()
  48.             turtle.forward()
  49.             turtle.turnLeft()
  50.         else
  51.             turtle.turnRight()
  52.             turtle.forward()
  53.             turtle.turnRight()
  54.         end
  55.     end
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement