theCountChuckula

turtle.bridge 1.99.7

Apr 15th, 2013
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local tArgs = { ... }
  2. if #tArgs ~= 1 then
  3.         print( "Usage: bridge <# of Sections>" )
  4.         return
  5. end
  6. local length = tonumber( tArgs[1] )
  7. if length < 1 then
  8.         print( "The number of sections to your bridge" )
  9.         print( "must be a positive number." )
  10.         print( " " )
  11.         print( "Each section is 31 blocks long plus an" )
  12.         print( "additional 3 at the end." )
  13.         print( "(If you choose [bridge 1] then you will" )
  14.         print( " need 34 blocks of space to build.)" )
  15.         print( "Press any key to continue..." )
  16.         os.pullEvent("char")
  17.         return
  18. end
  19.  
  20. term.clear()
  21. print( "*******************************" )
  22. print( "***********WELCOME!************" )
  23. print( "*******************************" )
  24. print( "********turtle.bridge()********" )
  25. print( "**************is***************" )
  26. print( "************ACTIVE*************" )
  27. print( "***Please read & follow all****" )
  28. print( "****instructions closely.******" )
  29. print( "*******************************" )
  30. print( "Press any key to continue..." )
  31. os.pullEvent("char")
  32. term.clear()
  33. print( "*******************************" )
  34. print( "*******turtle.bridge()*********" )
  35. print( "*****is brought to you by******" )
  36. print( "******theCountChuckula*********" )
  37. print( "*******************************" )
  38. print( "Press any key to continue..." )
  39. os.pullEvent("char")
  40. term.clear()
  41. print( "Place 2+ Block-Auto-Re-Filled" )
  42. print( "Ender Chests into Slot 1." )
  43. print( "Place 2+ Fuel-Auto-Re-Filled" )
  44. print( "Ender Chests into Slot 2." )
  45. print( "Place 2+ Auto-Sorting" )
  46. print( "Ender Chests into Slot 3." )
  47. print( "Press any key to continue..." )
  48. os.pullEvent("char")
  49. term.clear()
  50. print( "I mean it. At least 2 of each chest!" )
  51. print( "When the turtle places one, it uses" )
  52. print( "the extras as a placeholder to prevent" )
  53. print( "errors." )
  54. print( "Press any key to continue..." )
  55. os.pullEvent("char")
  56. term.clear()
  57. local dist = ((length * 31) + 3)
  58. print( "Turtle will build a bridge ", dist )
  59. print( "blocks long!" )
  60. print( " " )
  61. print( "If you didn't plan for that much" )
  62. print( "space, use CTRL+T to cancel the" )
  63. print( "program." )
  64. print( "Press any key to continue..." )
  65. os.pullEvent("char")
  66. term.clear()
  67. shell.run( "refuel all" )
  68.  
  69. local function ascend()
  70.   while turtle.detectUp() do
  71.     turtle.digUp()
  72.     sleep(1)
  73.   end
  74.   turtle.up()
  75.   turtle.select(16)
  76.   turtle.placeDown()
  77. end
  78. local function descend()
  79.   turtle.digDown() 
  80.   turtle.down()
  81. end
  82. local function refuel()
  83.   turtle.select(5)
  84.   while turtle.detectUp() do
  85.     turtle.digUp()
  86.     sleep(1)
  87.   end
  88.   turtle.select(2)
  89.   turtle.placeUp()
  90.   turtle.select(15)
  91.   turtle.suckUp()
  92.   shell.run("refuel all")
  93.   turtle.select(2)
  94.   turtle.digUp()
  95. end
  96. local function restock()
  97.   turtle.select(5)
  98.   while turtle.detectUp() do
  99.     turtle.digUp()
  100.     sleep(1)
  101.   end
  102.   turtle.select(1)
  103.   turtle.placeUp()
  104.   turtle.select(16)
  105.   turtle.suckUp()
  106.   turtle.select(1)
  107.   turtle.digUp()
  108. end
  109.  
  110. local function unload()
  111.   turtle.select(5)
  112.   while turtle.detectUp() do
  113.     turtle.digUp()
  114.     sleep(1)
  115.   end
  116.   turtle.select(3)
  117.   turtle.placeUp()
  118.   for s = 4, 14 do
  119.     turtle.select(s)
  120.     turtle.dropUp()
  121.   end
  122.   turtle.select(3)
  123.   turtle.digUp()
  124. end
  125.  
  126. local function checks()
  127.  
  128.   if turtle.getFuelLevel() < 140 then
  129.     refuel()
  130.   end
  131.  
  132.   if turtle.getItemCount(16) < 64 then
  133.     restock()
  134.   end
  135.  
  136. end
  137.  
  138. local function surface()
  139.   if turtle.getItemCount(16) < 4 then
  140.     checks()
  141.     unload()
  142.   end
  143.   if turtle.getFuelLevel() < 4 then
  144.     checks()
  145.     unload()
  146.   end
  147.   turtle.turnLeft()
  148.   turtle.select(16)
  149.   while turtle.detect() do
  150.     turtle.dig()
  151.     sleep(1)
  152.   end
  153.   turtle.place()
  154.   turtle.turnRight()
  155.   turtle.turnRight()
  156.   turtle.select(16)
  157.   while turtle.detect() do
  158.     turtle.dig()
  159.     sleep(1)
  160.   end
  161.   turtle.place()
  162.   turtle.turnLeft()
  163.   ascend()
  164.   while turtle.detectUp() do
  165.     turtle.digUp()
  166.     sleep(1)
  167.   end
  168.   while turtle.detect() do
  169.     turtle.dig()
  170.     sleep(1)
  171.   end
  172.   turtle.forward()
  173. end
  174.  
  175. local function pillar()
  176.   checks()
  177.   unload()
  178.  
  179.   for i = 1, 63 do
  180.     descend()
  181.   end
  182.  
  183.   for i = 1, 62 do
  184.     ascend()
  185.   end
  186.   surface()
  187. end
  188.  
  189. local function beginArch()
  190.  
  191.   checks()
  192.   unload()
  193.  
  194.   for i = 1, 11 do
  195.     descend()
  196.   end
  197.  
  198.   for i = 1, 10 do
  199.     ascend()
  200.   end
  201.   surface()
  202.   for i = 1, 9 do
  203.     descend()
  204.   end
  205.  
  206.   for i = 1, 8 do
  207.     ascend()
  208.   end
  209.   surface()
  210.   for i = 1, 6 do
  211.     descend()
  212.   end
  213.  
  214.   for i = 1, 5 do
  215.     ascend()
  216.   end
  217.   surface()
  218.   for i = 1, 4 do
  219.     descend()
  220.   end
  221.  
  222.   for i = 1, 3 do
  223.     ascend()
  224.   end
  225.   surface()
  226.   for i = 1, 3 do
  227.     descend()
  228.   end
  229.  
  230.   for i = 1, 2 do
  231.     ascend()
  232.   end
  233.   surface()
  234.   for i = 1, 3 do
  235.     descend()
  236.   end
  237.  
  238.   for i = 1, 2 do
  239.     ascend()
  240.   end
  241.   surface()
  242.   for i = 1, 2 do
  243.     descend()
  244.   end
  245.   ascend()
  246.   surface()
  247.   for i = 1, 2 do
  248.     descend()
  249.   end
  250.   ascend()
  251.   surface()
  252.   for i = 1, 2 do
  253.     descend()
  254.   end
  255.   ascend()
  256.   surface()
  257.  
  258. end
  259.  
  260. local function endArch()
  261.  
  262.   checks()
  263.   unload()
  264.  
  265.   for i = 1, 2 do
  266.     descend()
  267.   end
  268.   ascend()
  269.   surface()
  270.   for i = 1, 2 do
  271.     descend()
  272.   end
  273.   ascend()
  274.   surface()
  275.   for i = 1, 2 do
  276.     descend()
  277.   end
  278.   ascend()
  279.   surface()
  280.   for i = 1, 3 do
  281.     descend()
  282.   end
  283.  
  284.   for i = 1, 2 do
  285.     ascend()
  286.   end
  287.   surface()
  288.   for i = 1, 3 do
  289.     descend()
  290.   end
  291.  
  292.   for i = 1, 2 do
  293.     ascend()
  294.   end
  295.   surface()
  296.   for i = 1, 4 do
  297.     descend()
  298.   end
  299.  
  300.   for i = 1, 3 do
  301.     ascend()
  302.   end
  303.   surface()
  304.   for i = 1, 6 do
  305.     descend()
  306.   end
  307.  
  308.   for i = 1, 5 do
  309.     ascend()
  310.   end
  311.   surface()
  312.   for i = 1, 9 do
  313.     descend()
  314.   end
  315.  
  316.   for i = 1, 8 do
  317.     ascend()
  318.   end
  319.   surface()
  320.   for i = 1, 11 do
  321.     descend()
  322.   end
  323.  
  324.   for i = 1, 10 do
  325.     ascend()
  326.   end
  327.   surface()
  328.  
  329. end
  330.  
  331. local function path()
  332.   descend()
  333.   for i = 1, 10 do
  334.     surface()
  335.     descend()
  336.   end
  337.   ascend()
  338. end
  339.  
  340. for l = 1, length do
  341. pillar()
  342. pillar()
  343. pillar()
  344. beginArch()
  345. path()
  346. endArch()
  347. end
  348. pillar()
  349. pillar()
  350. pillar()
Advertisement
Add Comment
Please, Sign In to add comment