GNOOR1S

Floor Builder - 7/5/22

Aug 29th, 2019 (edited)
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.42 KB | None | 0 0
  1. -- Created by Gunnar Jessee/GNOOR1S
  2. -- 7/5/22
  3.  
  4. local tArgs = {...}
  5.  
  6. if #tArgs < 2 then
  7.     print("use 'floor [length] [width]")
  8.     return
  9. end
  10.  
  11. local direction = {left = "left", right = "right"}
  12. local length = tArgs[1]
  13. local width = tArgs[2]
  14. local currentDirection = direction.right
  15. local selectedSlot = 1
  16.  
  17. function fuel()
  18.     if turtle.getFuelLevel() < 10 then
  19.         turtle.select(16)
  20.         turtle.refuel(1)
  21.         turtle.select(selectedSlot)
  22.     end
  23. end
  24.  
  25. function turn()
  26.     if currentDirection == direction.right then
  27.         turtle.turnRight()
  28.         turtle.forward()
  29.         turtle.turnRight()
  30.         currentDirection = direction.left
  31.    
  32.     elseif currentDirection == direction.left then
  33.         turtle.turnLeft()
  34.         turtle.forward()
  35.         turtle.turnLeft()
  36.         currentDirection = direction.right
  37.     end
  38. end
  39.  
  40. function checkInv()
  41.     if turtle.getItemCount(selectedSlot) < 1 then
  42.         selectedSlot = selectedSlot + 1
  43.         turtle.select(selectedSlot)
  44.         if selectedSlot == 16 then
  45.             selectedSlot = 1
  46.             turtle.select(selectedSlot)
  47.             checkInv()
  48.         end
  49.         checkInv()
  50.     end
  51. end
  52.  
  53. function run()
  54.     for x = 1, width do
  55.         for z = 1, length do
  56.             fuel()
  57.             checkInv()
  58.             turtle.placeDown()
  59.             turtle.forward()
  60.         end
  61.         turtle.back()
  62.         turn()
  63.     end
  64.  
  65. end
  66.  
  67. run()
Add Comment
Please, Sign In to add comment