Advertisement
RabidxOtaku

3x5Stairs

Jul 28th, 2014
1,523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.60 KB | None | 0 0
  1. depth = 0
  2. write("Stairs = slot 1-3, Coal(or any fuel source) = slot 4-5, Torches = slot 6-7. ~ Now what is the depth of stairs you would fancy?: ")
  3. depth = read()
  4. depthNew = depth - 1
  5. stairAmount = depth * 3
  6. currentStair = turtle.getItemCount(1) + turtle.getItemCount(2) + turtle.getItemCount(3)
  7. ItemFuel = turtle.getItemCount(4) + turtle.getItemCount(5)
  8. local Fuel = 0
  9. local NeedFuel = 0
  10. torches = (depth / 6) * 2
  11. torch = 5
  12. straif = 0
  13.  
  14. --Functions
  15. function turnAround()
  16.     turtle.turnLeft()
  17.     turtle.turnLeft()
  18. end
  19. function goForward()
  20.     while turtle.detect() do
  21.         turtle.dig()
  22.     end
  23.     turtle.forward()
  24. end
  25. function goDown()
  26.     while turtle.detectDown() do
  27.         turtle.digDown()
  28.     end
  29.     turtle.down()
  30. end
  31. function goUp()
  32.     while turtle.detectUp() do
  33.         turtle.digUp()
  34.     end
  35.     turtle.up()
  36. end
  37. function torchMe()
  38.     torch1 = 0
  39.     if turtle.getItemCount(6) > 0 then
  40.         stair1 = 1
  41.     elseif turtle.getItemCount(7) > 0 then
  42.         stair1 = 2
  43.     end
  44.    
  45.     if stair1 == 1 then
  46.         turtle.select(6)
  47.         turtle.place()
  48.     elseif stair1 == 2 then
  49.         turtle.select(7)
  50.         turtle.place()
  51.     end
  52. end
  53. function stairMe()
  54.     stair1 = 0
  55.     if turtle.getItemCount(1) > 0 then
  56.         stair1 = 1
  57.     elseif turtle.getItemCount(2) > 0 then
  58.         stair1 = 2
  59.     elseif turtle.getItemCount(3) > 0 then
  60.         stair1 = 3
  61.     end
  62.    
  63.     if stair1 == 1 then
  64.         turtle.select(1)
  65.         turtle.place()
  66.     elseif stair1 == 2 then
  67.         turtle.select(2)
  68.         turtle.place()
  69.     elseif stair1 == 3 then
  70.         turtle.select(3)
  71.         turtle.place()
  72.     end
  73. end
  74. function mine()
  75.     while turtle.detect() do
  76.         turtle.dig()
  77.     end
  78. end
  79. function mineUp()
  80.     while turtle.detectUp() do
  81.         turtle.digUp()
  82.     end
  83. end
  84. function mineDown()
  85.     while turtle.detectDown() do
  86.         turtle.digDown()
  87.     end
  88. end
  89. function trippleMine()
  90.     goForward()
  91.     while turtle.detectUp() or turtle.detectDown() do
  92.         turtle.digUp()
  93.         turtle.digDown()
  94.     end
  95. end
  96. function check()
  97.   if ItemFuel == 0 then
  98.     print("No Fuel Items")
  99.   else
  100.     print("there is fuel")
  101.   end
  102.   repeat
  103.     if turtle.getFuelLevel() == "unlimited" then
  104.       print("NO NEED FOR FUEL")
  105.       Needfuel = 0
  106.     elseif turtle.getFuelLevel() < 100 then
  107.         if turtle.getItemCount(4) > 0 then
  108.             turtle.select(4)
  109.             turtle.refuel(1)
  110.         elseif turtle.getFuelLevel(5) > 0 then
  111.             turtle.select(4)
  112.             turtle.refuel(1)
  113.         end
  114.       Needfuel = 1
  115.       ItemFuel = ItemFuel - 1
  116.     elseif NeedFuel == 1 then
  117.       Needfuel = 0
  118.     end
  119.   until NeedFuel == 0
  120. end
  121. function mineSides()
  122.     turtle.turnLeft()
  123.     mine()
  124.     turnAround()
  125.     mine()
  126.     turtle.turnLeft()
  127. end
  128. --logical functions
  129. function wholeEnd()
  130.         check()
  131.         --1
  132.         goUp()
  133.         goForward()
  134.         goUp()
  135.         turtle.turnLeft()
  136.         mine()
  137.         turnAround()
  138.         mine()
  139.         --2
  140.         goDown()
  141.         mine()
  142.         torchMe()
  143.         turnAround()
  144.         mine()
  145.         torchMe()
  146.         --3
  147.         goDown()
  148.         mine()
  149.         turnAround()
  150.         mine()
  151.         --4
  152.         goDown()
  153.         mine()
  154.         turnAround()
  155.         mine()
  156.         --5
  157.         goDown()
  158.         mine()
  159.         turnAround()
  160.         mine()
  161.         goForward()
  162.         turtle.turnRight()
  163.        
  164.         torch = 0
  165. end
  166. function stair()
  167.     if straif == 0 then
  168.         stairMe()
  169.         turtle.turnRight()
  170.         goForward()
  171.         turtle.turnLeft()
  172.         stairMe()
  173.         turtle.turnRight()
  174.         goForward()
  175.         turtle.turnLeft()
  176.         stairMe()
  177.         goUp()
  178.         goForward()
  179.         straif = straif + 1
  180.     elseif straif == 1 then
  181.    
  182.     stairMe()
  183.         turtle.turnLeft()
  184.         goForward()
  185.         turtle.turnRight()
  186.         stairMe()
  187.         turtle.turnLeft()
  188.         goForward()
  189.         turtle.turnRight()
  190.         stairMe()
  191.         goUp()
  192.         goForward()
  193.        
  194.         straif = 0
  195.     end
  196. end
  197. function whole()
  198.     check()
  199.     if torch == 5 then
  200.         --1
  201.         goUp()
  202.         turtle.turnLeft()
  203.         mine()
  204.         turnAround()
  205.         mine()
  206.         --2
  207.         goDown()
  208.         mine()
  209.         torchMe()
  210.         turnAround()
  211.         mine()
  212.         torchMe()
  213.         --3
  214.         goDown()
  215.         mine()
  216.         turnAround()
  217.         mine()
  218.         --4
  219.         goDown()
  220.         mine()
  221.         turnAround()
  222.         mine()
  223.         --5
  224.         goDown()
  225.         mine()
  226.         turnAround()
  227.         mine()
  228.         turtle.turnLeft()
  229.         --6
  230.         goUp()
  231.         --7
  232.         goUp()
  233.  
  234.         torch = 0
  235.     elseif torch < 6 then
  236.         --1
  237.         goUp()
  238.         turtle.turnLeft()
  239.         mine()
  240.         turnAround()
  241.         mine()
  242.         --2
  243.         goDown()
  244.         mine()
  245.         turnAround()
  246.         mine()
  247.         --3
  248.         goDown()
  249.         mine()
  250.         turnAround()
  251.         mine()
  252.         --4
  253.         goDown()
  254.         mine()
  255.         turnAround()
  256.         mine()
  257.         --5
  258.         goDown()
  259.         mine()
  260.         turnAround()
  261.         mine()
  262.         turtle.turnLeft()
  263.         --6
  264.         goUp()
  265.         --7
  266.         goUp()
  267.  
  268.         torch = torch + 1
  269.     end
  270. end
  271. torchAmount = turtle.getItemCount(6) + turtle.getItemCount(7)
  272. if currentStair < stairAmount then
  273.         print( "You will need "..stairAmount.." pieces of any kind of stairs in slot 1-3. Press Y once filled or Press N to continue with out stairs")
  274.         while true do
  275.                 local _, char = os.pullEvent( "char" )
  276.                 if char:lower() == "n" then
  277.                         error()
  278.                 elseif char:lower() == "y" then
  279.                         break
  280.                 end
  281.         end
  282. end
  283. if torchAmount == 0 then
  284.         print("you will need around "..torches.." torches in slot 3. Press Y once filled or Press N to continue with out torches")
  285.         while true do
  286.                 local _, char = os.pullEvent( "char" )
  287.                 if char:lower() == "n" then
  288.                         error()
  289.                 elseif char:lower() == "y" then
  290.                         break
  291.                 end
  292.         end
  293. end
  294.  
  295. --StartMain
  296. for i = 1,depthNew do
  297.     check()
  298.     whole()
  299.     goForward()
  300. end
  301. for i = 1,1 do
  302.     check()
  303.     whole()
  304. end
  305. --EndMain
  306.  
  307. --StartSecondary
  308. for i = 1,1 do
  309.     check()
  310.     wholeEnd()
  311. end
  312. --EndSecondary
  313. currentStair = turtle.getItemCount(1) + turtle.getItemCount(2) + turtle.getItemCount(3)
  314. --StartStairs
  315. if currentStair < stairAmount then
  316.     print("Done!")
  317. else
  318.    
  319.     for i = 1,depth do
  320.         stair()
  321.     end
  322.    
  323.     print("Done!")
  324. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement