Advertisement
MWozz

fluid clearer

Feb 23rd, 2020
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.42 KB | None | 0 0
  1. term.clear()
  2. print("1: fuel\n2-16: blocks\n\nEnter x:")
  3. x = read()
  4. term.clear()
  5. print("Enter y:")
  6. y = read()
  7. term.clear()
  8.  
  9. function refuel()
  10.     local savedSlot = turtle.getSelectedSlot()
  11.     turtle.select(1)
  12.    
  13.     while(not turtle.refuel(10))
  14.     do
  15.         write("Out of fuel! Place more fuel in slot 1 and press enter.")
  16.         read()
  17.         term
  18.         .clear()
  19.     end
  20.     turtle.select(savedSlot)
  21. end
  22.  
  23. function tryRefuel()
  24.     if turtle.getFuelLevel() < 100 then refuel() end
  25. end
  26.  
  27. function digForward()
  28.     tryRefuel()
  29.  
  30.     while(turtle.detect())
  31.     do
  32.         turtle.dig()
  33.     end
  34.  
  35.     turtle.forward()
  36. end
  37.  
  38. function placeBlock()
  39.     if turtle.detectDown() then return end
  40.    
  41.     local savedSlot = turtle.getSelectedSlot()
  42.     blockSlot = 2
  43.     turtle.select(blockSlot)
  44.    
  45.     while(not turtle.placeDown())
  46.     do
  47.         blockSlot = blockSlot+1
  48.         if blockSlot == 17
  49.         then
  50.             write("Out of blocks! Place more blocks in slots 2-16 and press enter.")
  51.             read()
  52.             term.clear()
  53.             blockSlot = 2
  54.         end
  55.        
  56.         turtle.select(blockSlot)
  57.     end
  58.    
  59.     turtle.select(savedSlot)
  60. end
  61.  
  62. function line()
  63.     placeBlock()
  64.     for i = 1,x
  65.     do
  66.         digForward()
  67.         placeBlock()
  68.     end
  69. end
  70.  
  71. function square()
  72.     for i = 1,y/2
  73.     do
  74.         line()
  75.         turtle.turnRight()
  76.         digForward()
  77.         turtle.turnRight()
  78.         line()
  79.         turtle.turnLeft()
  80.         digForward()
  81.         turtle.turnLeft()
  82.     end
  83.     line()
  84.     turtle.turnLeft()
  85.     turtle.turnLeft()
  86. end
  87.  
  88. while(true)
  89. do
  90.     square()
  91.     turtle.digDown()
  92.     turtle.down()
  93. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement