Advertisement
ceed24

Mod Farm Sky Factory 2 Builder

Nov 18th, 2015
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.96 KB | None | 0 0
  1. -- Sky Factory 2 build Farming mods 25 blocks away from you base
  2. -- Requires:
  3. -- Slot 1,15 Resources
  4. -- Slot 16, Coal
  5. -- this turtle builds form left to right
  6. -- place turtle on block next to the platform that you wanna build
  7. -- it's a 18x18 mob farm so You will need 19 stack of cobblestone to build it
  8.  
  9. local Moveto ="r"
  10. local NextSlot
  11. local lastslotValid=1
  12. local ResourcesAmount=1
  13. local width
  14. local length
  15. local function NextSelect()
  16.     for i = lastslotValid, 15 do
  17.                 turtle.select(i)
  18.                         itemCount = turtle.getItemCount(i)
  19.                         if itemCount ~= 0 then
  20.                                 NextSlot=i
  21.                                 lastslotValid=i
  22.                                 ResourcesAmount=1
  23.                                 break
  24.                         else
  25.                                 lastslotValid=i
  26.                                 NextSlot=i
  27.                                 ResourcesAmount=0                              
  28.                         end
  29.                  end
  30. end
  31. function MoveBack()
  32. NextSelect()
  33. turtle.select(NextSlot)
  34. turtle.back()
  35. turtle.place()
  36. end
  37. function MoveIt()
  38. NextSelect()
  39. turtle.select(NextSlot)
  40. turtle.turnLeft()
  41. turtle.back()
  42. turtle.down()
  43. end
  44. function MoveItleft()
  45. NextSelect()
  46. turtle.select(NextSlot)
  47. turtle.turnRight()
  48. turtle.back()
  49. turtle.place()
  50. turtle.turnRight()
  51. end
  52. function MoveItRight()
  53. NextSelect()
  54. turtle.select(NextSlot)
  55. turtle.turnLeft()
  56. turtle.back()
  57. turtle.place()
  58. turtle.turnLeft()
  59. end
  60. local function GetResources()
  61. local OneSlotFull
  62.         for i = 1, 15 do
  63.                         turtle.select(i)
  64.                         itemCount = turtle.getItemCount(i)
  65.                         if itemCount ~= 0 then
  66.                                 OneSlotFull=true                      
  67.                         end
  68.                        
  69.         end
  70.                 if OneSlotFull then
  71.                 return true
  72.                 else
  73.                 print("No Resources feed Me ")
  74.                 return false
  75.                 end
  76. end
  77. local function TurtleReFuel()
  78.         for i = 1, 16 do
  79.          turtle.select(i)
  80.         if turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 1 then
  81.         turtle.refuel()
  82.                 end
  83.         end
  84.                 turtle.select(1)
  85.                 if turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 1 then
  86.                 print("your turtle needs fuel to move put some into last slot")
  87.                 return false
  88.                 else
  89.                 return true
  90.                 end
  91. end
  92. function addmoreresources()
  93. while ResourcesAmount==0 do
  94. print("add more resources and Press Enter to continue!")
  95. local event, key = os.pullEvent( "key" )
  96.        
  97.         if key == keys.enter then
  98.         print( "Let's Go !")
  99.         lastslotValid=1
  100.         NextSelect()
  101.         turtle.place()
  102.         end            
  103.         end
  104. while turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 1 do
  105. print("your turtle needs fuel to move put some into last slot")
  106. turtle.select(16)
  107. turtle.refuel()
  108. turtle.select(1)
  109. turtle.place()
  110. end
  111. end
  112.  
  113. function BuildSquareTunnel(D1,D2)
  114. for i=1,D1 do
  115.         for j=1,4 do
  116.                 for i=1,D2 do
  117.                         MoveBack()                                                              
  118.                         addmoreresources()                        
  119.                 end    
  120.                 turtle.turnRight()                                    
  121.         end
  122.         MoveBack()
  123.         turtle.turnRight()
  124.         turtle.up()    
  125.         turtle.forward()
  126.         turtle.turnLeft()      
  127.         turtle.forward()      
  128.         end
  129.        
  130. end    
  131. local SurfacesDims = {{25,3},{12,11},{18,18}}
  132. function GotoThecenter()
  133.  
  134.                         turtle.up()
  135.                         turtle.turnLeft()
  136.                 for i=1,8 do
  137.                 turtle.forward()
  138.                 end
  139.                 turtle.turnLeft()
  140.                 for i=1,4 do
  141.                 turtle.forward()
  142.                 end
  143. end
  144.  
  145. function BuildNextPlatform()
  146. NextSelect()
  147. turtle.select(NextSlot)
  148. turtle.up()
  149. turtle.turnLeft()
  150. for i = 1, 7 do
  151. turtle.forward()
  152. end
  153. Moveto ="r"
  154. MoveIt()
  155. end    
  156.  
  157. function buildPlatfurms(a,y)
  158.  local Dim1=SurfacesDims[a][1]
  159.  local Dim2=SurfacesDims[a][2]
  160. for j=1,Dim2 do
  161.                 for i=1,Dim1-1 do              
  162.                         if  y==1 and (i==9 or i==10) and (j==9 or j==10)  then
  163.                                         turtle.back()                                      
  164.                         else
  165.                                         MoveBack()                                                              
  166.                                         addmoreresources()    
  167.                         end                                                      
  168.             end
  169.                                         if Moveto =="r"  then
  170.                                         MoveItleft()
  171.                                         Moveto = "l"
  172.                                         else
  173.                                         MoveItRight()
  174.                                         Moveto = "r"  
  175.                                         end                                      
  176. end
  177. end
  178. if  GetResources() and TurtleReFuel() then
  179.                        
  180.         MoveIt()
  181.         buildPlatfurms(1)
  182.         BuildNextPlatform()
  183.         buildPlatfurms(2)
  184.         GotoThecenter()
  185.         BuildSquareTunnel(18,3)
  186.         turtle.turnRight()
  187.         for i=1,2 do
  188.         if i==2 then
  189.         turtle.turnLeft()
  190.         end
  191.         for i=1,7 do
  192.                 turtle.forward()
  193.         end    
  194.         end
  195.         Moveto = "r"
  196.         buildPlatfurms(3,1)
  197.         turtle.up()
  198.         turtle.turnRight()
  199.         for j=1,18 do
  200.         turtle.forward()
  201.         end
  202.         turtle.turnLeft()
  203.         BuildSquareTunnel(3,17)
  204.         buildPlatfurms(3)
  205.        
  206. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement