wartos

tunnel2

Mar 25th, 2022
1,353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.70 KB | None | 0 0
  1. print("Fuel in slot1")
  2. print("Cobblestone in slot 2+ (as much as needed)")
  3. print("bridge length:")
  4. local blength = 1
  5. local step = 0
  6. local cobSlot = 2
  7. blength=tonumber(read())
  8. print("tunnel height(1):")
  9. theight=tonumber(read())
  10.  
  11. function invCheck(cobSlot)
  12.     if turtle.getItemCount(cobSlot) < 5 then
  13.         print("no cobblestone, searching")
  14.         cobSlot = invSelect()
  15.     end
  16.     return cobSlot
  17. end
  18.  
  19. function heightCheck(theight)
  20.     if theight == "" then
  21.        theight = 1
  22.     end
  23.     return theight
  24. end
  25.  
  26. function invSelect()
  27.     local cobSlot = -1
  28.    
  29.     for i=1,16 do
  30.             if turtle.getItemDetail(i) ~= nil then
  31.                 if (turtle.getItemDetail(i).name == "minecraft:cobblestone" and turtle.getItemCount(i) > 5)  then
  32.                     print("cobblestone found in slot".. i )
  33.                     cobSlot = i
  34.                    
  35.                     --i = 16
  36.                     break
  37.                 end
  38.             end
  39.     end
  40.     return cobSlot    
  41. end
  42.  
  43. function tmf()
  44.     -- turtle move forward
  45.     while turtle.forward() == false do
  46.         turtle.dig()
  47.         turtle.attack()
  48.     end
  49. end
  50.  
  51. function tpf()
  52.     --turtle place forward
  53.     --turtle.select(2)
  54.     turtle.place()
  55. end
  56.  
  57. function tpd()
  58.     --turtle place down
  59.     --turtle.select(2)
  60.     turtle.placeDown()
  61. end    
  62.  
  63. function tmu()
  64.     turtle.digUp()
  65.     turtle.up()
  66. end
  67.  
  68. function fuelCheck()
  69.     if turtle.getFuelLevel() < 80 then
  70.         if turtle.getItemCount(1) >=1 then
  71.             turtle.select(1)
  72.             turtle.refuel(1)
  73.         else
  74.             print("low on fuel")
  75.             os.shutdown()
  76.         end
  77.     end
  78. end
  79.  
  80. function row(cobSlot)
  81.     cobSlot = invCheck(cobSlot)
  82.     print("using items from Slot".. cobSlot)
  83.     turtle.select(cobSlot)
  84.     tpd()
  85.     turtle.turnLeft()
  86.     tmf()
  87.     tpd()
  88.     tpf()
  89.     turtle.turnRight()
  90.     turtle.turnRight()
  91.     tmf()
  92.     tmf()
  93.     tpf()
  94.     tpd()
  95.     turtle.turnLeft()
  96.     turtle.turnLeft()
  97.     tmf()
  98.     turtle.turnRight()
  99. end    
  100.  
  101. function rowup(cobslot)
  102.     turtle.turnLeft()
  103.     turtle.dig()
  104.     turtle.turnRight()
  105.     turtle.turnRight()
  106.     turtle.dig()
  107.     turtle.turnLeft()    
  108. end
  109.  
  110. function goback(step)
  111.     turtle.turnRight()
  112.     turtle.turnRight()
  113.     while step > 0 do
  114.         fuelCheck()
  115.         tmf()
  116.         step = step - 1
  117.     end
  118. end
  119.  
  120. function highRow(theight)
  121.     -- höhenkram
  122.     rowheight = theight
  123.     while rowheight > 1 do
  124.         tmu()
  125.         rowup()
  126.         rowheight = rowheight -1
  127.     end
  128.    
  129.     while rowheight < theight do
  130.         turtle.down()
  131.         rowheight = rowheight +1
  132.     end
  133.    
  134. end
  135.    
  136. theight = heightCheck(theight)
  137. while step < blength do
  138.     fuelCheck()
  139.     tmf()
  140.     row(cobSlot)
  141.     highRow(theight)
  142.     step = step + 1
  143. end
  144.  
  145. goback(blength)
  146.  
Advertisement
Add Comment
Please, Sign In to add comment