Guest User

Windmill Placer

a guest
Jun 29th, 2013
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.94 KB | None | 0 0
  1. --  
  2. --      Windmill Placer v1.0 by Joseph Jones
  3. --
  4. --      Instructions found at:
  5. --
  6. --
  7. --      Needs 420 cables.   Uses slots 1-14
  8. --      Needs 60 windmills. Uses slot 15
  9. --      Needs 960 fuel.     Uses slot 16
  10. --
  11. --
  12. --      ChangeLog:
  13. --          June 29, 2013: [v1.0] Finished initial release
  14. --
  15.  
  16.  
  17. local currWireSlot = 1
  18.  
  19.  
  20. --Checks the number of wires in curr slot and changes if 0
  21. function checkWireCountInSlot()
  22.     --Checks the slot with wires to see if there are wires
  23.     while(turtle.getItemCount(currWireSlot)==0) do
  24.         currWireSlot = currWireSlot + 1    
  25.        
  26.         --checks to make sure there are wires in the inventory
  27.         if(currWireSlot==15) then
  28.             print("There is not enough cable.")
  29.             print("Press enter to continue.")
  30.             io.read()
  31.             currWireSlot=1
  32.         end
  33.        
  34.         turtle.select(currWireSlot)
  35.     end
  36. end
  37.  
  38.  
  39. function forwardPlaceCable()
  40.     checkWireCountInSlot()
  41.     while (turtle.forward()==false) do end
  42.     turtle.placeDown()
  43. end
  44.  
  45.  
  46. function placeWindmill()
  47.     while (turtle.up()==false) do end
  48.     checkWireCountInSlot()
  49.     turtle.placeDown()
  50.    
  51.     while (turtle.up()==false) do end
  52.     checkWireCountInSlot()
  53.     turtle.placeDown()
  54.    
  55.     while (turtle.up()==false) do end
  56.     turtle.select(15)
  57.     --checks to make sure there are windmills in the inventory
  58.     while(turtle.getItemCount(15)==0) do
  59.         print("There is not enough windmills in slot 15.")
  60.         print("Press enter to continue.")
  61.         io.read()
  62.     end
  63.     turtle.placeDown()
  64.    
  65.     turtle.select(currWireSlot)
  66.    
  67.  
  68. end
  69.  
  70.  
  71. function placeWings(numOfWindMills)
  72.     local temp = numOfWindMills - 1
  73.     temp = temp * 5
  74.    
  75.     while(temp>0) do
  76.         forwardPlaceCable()
  77.         temp = temp - 1
  78.     end
  79.    
  80.     temp = numOfWindMills - 1
  81.     placeWindmill()
  82.     while(temp>0) do
  83.         if(temp>0) then
  84.             while (turtle.back()==false) do end
  85.             while (turtle.down()==false) do end
  86.             while (turtle.down()==false) do end
  87.             while (turtle.down()==false) do end
  88.         end
  89.        
  90.         local temp2 = 4
  91.         while(temp2>0) do
  92.             while (turtle.back()==false) do end
  93.             temp2 = temp2 - 1
  94.         end
  95.        
  96.         placeWindmill()
  97.         temp = temp - 1
  98.     end
  99.    
  100.     turtle.turnRight()
  101.     while (turtle.forward()==false) do end
  102.     while (turtle.down()==false) do end
  103.     while (turtle.down()==false) do end
  104.     while (turtle.down()==false) do end
  105.    
  106. end
  107.  
  108.  
  109. --obtains 960 fuel at the beginning of the program
  110. function fuel()
  111.     turtle.select(16)
  112.     while(turtle.getFuelLevel() < 960) do
  113.         if(turtle.refuel(1)==false) then
  114.             print("Turtle needs more fuel in slot 16. Press enter to continue")
  115.             io.read()
  116.         end
  117.     end
  118.    
  119. end
  120.  
  121.  
  122. --Main program
  123. fuel()
  124. turtle.select(currWireSlot)
  125.  
  126. local currSide = 4
  127. while(currSide > 0) do
  128.     local temp = 25
  129.     while(temp>0) do
  130.         forwardPlaceCable()
  131.         temp = temp - 1
  132.     end
  133.    
  134.     temp = 1
  135.     turtle.turnRight()
  136.     while(temp<6) do
  137.         placeWings(temp)
  138.         temp = temp + 1
  139.         while (turtle.forward()==false) do end
  140.         while (turtle.forward()==false) do end
  141.         while (turtle.forward()==false) do end
  142.         while (turtle.forward()==false) do end
  143.         turtle.turnLeft()
  144.     end
  145.     currSide = currSide-1
  146. end
Advertisement
Add Comment
Please, Sign In to add comment