Advertisement
brensen11

StairCase

Mar 20th, 2021 (edited)
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.43 KB | None | 0 0
  1. local Stair_length = 0
  2. local slotCount = 16
  3. local blockSlot = 1
  4.  
  5. print("How long would you like your stairs?")
  6. Stair_length = tonumber(read())
  7.  
  8. if(Stair_length <= 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.place()) then
  31.             return true
  32.         end
  33.     end
  34.  
  35.     for slot = 1, slotCount do
  36.         turtle.select(slot)
  37.         if(turtle.place()) then
  38.             blockSlot = slot
  39.             return true
  40.         end
  41.     end
  42. end
  43.  
  44. function PlaceBlock()
  45.     if(turtle.place()) then
  46.         return true
  47.     elseif(CheckBlock()) then
  48.         return true
  49.     end
  50. end
  51.  
  52. function moveUpStairs()
  53.     turtle.up()
  54.     turtle.forward()
  55. end
  56.  
  57.  
  58. --Main-----------------------
  59.  
  60. for stair = 1, Stair_length do
  61.     if(CheckFuel()) then
  62.        if (PlaceBlock()) then
  63.             moveUpStairs()
  64.        else
  65.         print("Out of blocks to use")
  66.         return
  67.        end
  68.     else
  69.         print("No Fuel Detected")
  70.         return
  71.     end
  72. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement