Advertisement
brensen11

Bridge

Mar 21st, 2021 (edited)
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.43 KB | None | 0 0
  1. local bridgeLength = 0
  2. local slotCount = 16
  3. local blockSlot = 1
  4.  
  5. print("How long would you like your stairs?")
  6. bridgeLength = tonumber(read())
  7.  
  8. if(bridgeLength <= 0) then
  9.     print("Malformed Size Given")
  10.     return
  11. end
  12.  
  13. function CheckFuel()
  14.     if(turtle.getFuelLevel() < 10) then
  15.         for slot = 1, slotCount do
  16.             print("Attempting to refuel on slot " .. slot)
  17.             turtle.select(slot)
  18.             if(turtle.refuel(1)) then
  19.                 turtle.select(blockSlot)
  20.                 return true
  21.              end
  22.         end
  23.         return false
  24.     end
  25.     return true
  26. end
  27.  
  28. function CheckBlock()
  29.     if(turtle.getItemCount() > 0) then
  30.         if(turtle.placeDown()) then
  31.             return true
  32.         end
  33.     end
  34.  
  35.     for slot = 1, slotCount do
  36.         turtle.select(slot)
  37.         if(turtle.placeDown()) then
  38.             blockSlot = slot
  39.             return true
  40.         end
  41.     end
  42. end
  43.  
  44. function PlaceBlock()
  45.     if(turtle.placeDown()) then
  46.         return true
  47.     elseif(CheckBlock()) then
  48.         return true
  49.     end
  50. end
  51.  
  52. function moveForwards()
  53.     turtle.forward()
  54. end
  55.  
  56.  
  57. --Main-----------------------
  58.  
  59. for stair = 1, bridgeLength do
  60.     if(CheckFuel()) then
  61.        if (PlaceBlock()) then
  62.             moveForwards()
  63.        else
  64.         print("Out of blocks to use/Land Reached")
  65.         return
  66.        end
  67.     else
  68.         print("No Fuel Detected")
  69.         return
  70.     end
  71. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement