Aixler

Ender2

Sep 6th, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.74 KB | None | 0 0
  1. function printUsage()
  2.         print( "Usage:" )
  3.         print( "'Ender2 1' for first time use." )
  4.         print( "'Ender2 2' for 2nd time etc..." )
  5.         print( "'Ender2 #(f.e. 3) top' for last layer" )
  6. end
  7.  
  8. tArgs = { ... }
  9. if #tArgs > 2 or #tArgs < 1 then
  10.     printUsage()
  11.     return
  12. elseif tonumber(tArgs[1]) == nil then
  13.     printUsage()
  14.     return
  15. elseif #tArgs == 2 and tostring(tArgs[2]) ~= "top" then
  16.     printUsage()
  17.     return
  18. end
  19.  
  20.  
  21. slot = 1
  22. progress = tonumber(tArgs[1])
  23.  
  24. height = 32 + 16 * progress
  25.  
  26. print("'Turtle should (still) be in the bottom left corner on the ground'")
  27. print("'4 layers at a time:'")
  28. print("'slot 1-2 = pistons 1stack+40'")
  29. print("'slot 3 = slabs 1stack'")
  30. print("'slot 4-5 = string 1stack+40'")
  31. print("'slot 6 = tripwire hooks 16'")
  32. print("'slot 7-8 = redstone 1stack+56'")
  33. print("'slot 9-13- = blocks 4stacks+16'")
  34. print("Type anything to proceed")
  35. io.read()
  36.  
  37.  
  38. if tArgs[2] == "top" then
  39.     print("'top detected!'")
  40.     print("'Add 26 slabs to slot 16!'")
  41. else
  42.     print("'Remember: add top for the last layer'")
  43.     print("'For example: Ender2 5 top'")
  44. end
  45. print("'turtle backing up, made room?'")
  46. io.read()
  47.  
  48. function place()
  49.         inventory()
  50.         turtle.place()
  51. end
  52.  
  53. function placeUp()
  54.         inventory()
  55.         turtle.placeUp()
  56. end
  57.  
  58. function placeDown()
  59.         inventory()
  60.         turtle.placeDown()
  61. end
  62.  
  63. function inventory()
  64.         while turtle.getItemCount(slot) == 0 do
  65.                 slot = slot + 1
  66.         end
  67.         turtle.select(slot)
  68. end
  69.  
  70.                             --program begins here
  71. turtle.back()
  72. for x=1, height do
  73.     turtle.up()
  74. end
  75. turtle.forward()
  76.  
  77. function piston()
  78.     slot = 1
  79.     place()            
  80.     turtle.turnRight()
  81.     turtle.forward()
  82.     turtle.turnLeft()
  83. end
  84.  
  85. function redstone()
  86.     slot = 9
  87.     placeDown()        
  88.     turtle.back()
  89.     slot = 7
  90.     place()            
  91. end
  92.  
  93. function hook()
  94.     slot = 9
  95.     place()                
  96.     turtle.up()
  97.     slot = 3
  98.     place()                
  99.     turtle.down()
  100.     turtle.back()
  101.     slot = 6
  102.     place()                
  103. end
  104.    
  105. function layer()            --layer starts here
  106.     slot = 9
  107.     placeUp()               --block
  108.     for x=1, 4 do
  109.         turtle.forward()
  110.         slot = 3
  111.         placeUp()           --slabs
  112.     end
  113.     turtle.forward()
  114.     slot = 9
  115.     placeUp()               --block
  116.     turtle.back()
  117.     turtle.turnRight()
  118.     for x=1, 14 do          --move other side
  119.         turtle.forward()
  120.     end
  121.     turtle.turnRight()
  122.     turtle.back()
  123.     slot = 9
  124.     placeUp()               --block
  125.     turtle.forward()
  126.     for x=1, 4 do
  127.         slot = 3
  128.         placeUp()           --slabs
  129.         turtle.forward()
  130.     end
  131.     slot = 9
  132.     placeUp()               --block    
  133.     turtle.forward()
  134.     turtle.turnRight()
  135.     for x=1, 13 do
  136.         turtle.forward()    --move to start pistons
  137.     end
  138.     turtle.turnRight()
  139.     turtle.up()
  140.     for x=1, 13 do
  141.         piston()            --pistons
  142.     end
  143.     turtle.up()
  144.     turtle.up()
  145.     turtle.forward()
  146.     slot = 7
  147.     placeDown()             --place 1 redstone for the hook
  148.     turtle.turnRight()
  149.     turtle.back()
  150.     for x=1, 13 do
  151.         redstone()          --place blocks and redstone
  152.     end
  153.     slot = 7
  154.     placeDown()             --place 1 redstone for the hook
  155.     turtle.turnRight()
  156.     for x=1, 5 do
  157.         turtle.back()       --move to other side
  158.     end
  159.     slot = 7
  160.     placeDown()             --place 1 redstone for the hook
  161.     turtle.turnRight()
  162.     turtle.back()
  163.     for x=1, 13 do
  164.         redstone()          --place blocks and redstone
  165.     end
  166.     slot = 7
  167.     placeDown()             --place 1 redstone for the hook
  168.     turtle.turnLeft()
  169.     turtle.back()
  170.     turtle.down()
  171.     turtle.down()
  172.     turtle.turnRight()
  173.     turtle.forward()
  174.     turtle.turnLeft()
  175.     for x=1, 13 do
  176.         piston()            --pistons
  177.     end
  178.     turtle.up()
  179.     turtle.up()
  180.     turtle.up()
  181.     turtle.forward()
  182.     slot = 3
  183.     placeDown()             --place slab1
  184.     turtle.turnLeft()
  185.     for x=1, 14 do
  186.         turtle.forward()
  187.     end
  188.     turtle.turnRight()
  189.     slot = 3
  190.     placeDown()             --place slab2
  191.     for x=1, 5 do
  192.         turtle.forward()
  193.     end
  194.     turtle.turnRight()
  195.     slot = 3
  196.     placeDown()             --place slab3
  197.     for x=1, 14 do
  198.         turtle.forward()
  199.     end
  200.     turtle.turnRight()
  201.     slot = 3
  202.     placeDown()             --place slab4
  203.     turtle.forward()
  204.     turtle.turnLeft()
  205.     turtle.down()
  206.     turtle.down()
  207.     hook()
  208.     for x=1, 13 do
  209.         turtle.back()
  210.     end
  211.     turtle.turnRight()
  212.     turtle.turnRight()
  213.     hook()
  214.     turtle.turnLeft()
  215.     for x=1, 3 do
  216.         turtle.forward()
  217.     end
  218.     turtle.turnRight()
  219.     turtle.forward()
  220.     hook()
  221.     for x=1, 13 do
  222.         turtle.back()
  223.     end
  224.     turtle.turnRight()
  225.     turtle.turnRight()
  226.     hook()
  227.     for x=1, 12 do
  228.         turtle.back()
  229.         slot = 4
  230.         place()            
  231.     end
  232.     turtle.turnRight()
  233.     turtle.back()
  234.     slot = 4
  235.     place()                
  236.     for x=1, 3 do
  237.         turtle.back()
  238.     end
  239.     turtle.turnRight()
  240.     for x=1, 12 do
  241.         turtle.back()
  242.         slot = 4
  243.         place()            
  244.     end
  245.     turtle.turnRight()
  246.     turtle.back()
  247.     slot = 4
  248.     place()                
  249.     turtle.up()
  250.     turtle.up()
  251.     for x=1, 3 do
  252.         turtle.forward()
  253.     end
  254.     turtle.turnRight()
  255.     turtle.forward()
  256.     turtle.turnRight()
  257.     turtle.forward()
  258. end
  259.  
  260. function spawn()
  261.     for x=1, 4 do
  262.         turtle.forward()
  263.         slot = 9
  264.         placeDown()        
  265.     end
  266.     turtle.turnRight()
  267.     for x=1, 14 do
  268.         turtle.forward()
  269.         slot = 9
  270.         placeDown()        
  271.     end
  272.     turtle.turnRight()
  273.     for x=1, 3 do
  274.         turtle.forward()
  275.         slot = 9
  276.         placeDown()        
  277.     end
  278.     turtle.turnRight()
  279.     for x=1, 13 do
  280.         turtle.forward()
  281.         slot = 9
  282.         placeDown()        
  283.     end
  284.     turtle.forward()
  285.     turtle.turnRight()
  286.     turtle.back()
  287. end
  288.    
  289. for x=1, 4 do
  290.     spawn()
  291.     layer()
  292. end
  293.  
  294. if tostring(tArgs[2]) == "top" then
  295.     turtle.turnRight()
  296.     turtle.up()
  297.     for x=1, 13 do
  298.         turtle.forward()
  299.         slot = 16
  300.         placeDown()        
  301.     end
  302.     turtle.turnLeft()
  303.     for x=1, 5 do
  304.         turtle.forward()
  305.     end
  306.     turtle.turnLeft()
  307.     for x=1, 13 do
  308.         slot = 16
  309.         placeDown()        
  310.         turtle.forward()
  311.     end
  312.     turtle.turnLeft()
  313.     for x=1, 5 do
  314.         turtle.forward()
  315.     end
  316.     turtle.turnRight()
  317.     turtle.turnRight()
  318.     turtle.down()
  319. end
  320.  
  321. turtle.back()
  322. height = height + 16
  323. for x=1, height do
  324.     turtle.down()
  325. end
  326. turtle.forward()
  327.  
  328. print("'Ender2 is done!'")
  329. if tostring(tArgs[2]) == "top" then
  330.     print("Finished building, enjoy!")
  331. else
  332.     print("'Ready to go again!'")
  333. end
Advertisement
Add Comment
Please, Sign In to add comment