Advertisement
ceed24

Platform Craft

Nov 14th, 2015
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.45 KB | None | 0 0
  1. -- Minecraft Sky Factory 2 platforms Builder.
  2. -- Requires:
  3. -- Slot 1,15 Resources
  4. -- Slot 16, Coal
  5. -- Name your turtle by using the cmd : label set turtle
  6. -- this turtle builds form left to right
  7. -- place turtle on block next to the platform that you wanna build
  8.  
  9. local Moveto ="r"
  10. local NextSlot
  11. local lastslotValid=1
  12. local ResourcesAmount=1
  13. local width
  14. local length
  15. turtle.select(1)
  16. turtle.back()
  17. local function NextSelect()
  18.     for i = lastslotValid, 15 do
  19.         turtle.select(i)
  20.             itemCount = turtle.getItemCount(i)
  21.             if itemCount ~= 0 then
  22.                 NextSlot=i
  23.                 lastslotValid=i
  24.                 ResourcesAmount=1
  25.                 break
  26.             else
  27.                 lastslotValid=i
  28.                 NextSlot=i
  29.                 ResourcesAmount=0              
  30.             end
  31.          end
  32. end
  33.  
  34. function MoveBack()
  35. NextSelect()
  36. turtle.select(NextSlot)
  37. turtle.back()
  38. turtle.place()
  39. end
  40. function MoveIt()
  41. NextSelect()
  42. turtle.select(NextSlot)
  43. turtle.turnLeft()
  44. turtle.back()
  45. turtle.down()
  46. end
  47. function MoveItleft()
  48. NextSelect()
  49. turtle.select(NextSlot)
  50. turtle.turnRight()
  51. turtle.back()
  52. turtle.place()
  53. turtle.turnRight()
  54. end
  55. function MoveItRight()
  56. NextSelect()
  57. turtle.select(NextSlot)
  58. turtle.turnLeft()
  59. turtle.back()
  60. turtle.place()
  61. turtle.turnLeft()
  62. end
  63.  
  64. local function GetResources()
  65. local OneSlotFull
  66.         for i = 1, 15 do
  67.             turtle.select(i)
  68.             itemCount = turtle.getItemCount(i)
  69.             if itemCount ~= 0 then
  70.                 OneSlotFull=true           
  71.             end
  72.            
  73.         end
  74.         if OneSlotFull then
  75.         return true
  76.         else
  77.         print("No Resources feed Me ")
  78.         return false
  79.         end
  80. end
  81.  
  82. local function TurtleReFuel()
  83.         for i = 1, 16 do
  84.          turtle.select(i)
  85.         if turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 1 then
  86.         turtle.refuel()
  87.         end
  88.         end
  89.         turtle.select(1)
  90.         if turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 1 then
  91.         print("your turtle needs fuel to move put some into last slot")
  92.         return false
  93.         else
  94.         return true
  95.         end
  96. end
  97.  
  98. function  backtoYou(l,w)
  99. if width%2==0  then
  100.         turtle.up()
  101.         turtle.forward()
  102.         turtle.turnRight()
  103.             for i=1,width do
  104.                 turtle.forward()
  105.             end
  106. else
  107.         turtle.up()
  108.         turtle.turnLeft()
  109.         turtle.turnLeft()      
  110.             for i=1,length do
  111.                   turtle.forward()
  112.              end
  113.              
  114.              turtle.turnRight()
  115.              for i=1,width do
  116.                 turtle.forward()
  117.             end
  118.            
  119. end
  120. end
  121.  
  122. print ("Enter the length:")
  123. local inputL = read()
  124. while tonumber(inputL) == nil or tonumber(inputL) < 1 do
  125. print("You incorrectly enter the length . must be sup then 1.")
  126. write ("Enter the  length :")
  127. inputL = read()
  128. end
  129. length = tonumber(inputL)
  130.  
  131. print ("Enter the width:")
  132. local inputW = read()
  133. while tonumber(inputW) == nil or tonumber(inputW) < 1 do
  134. print("You incorrectly enter the width . must be sup then 1.")
  135. write("Enter the  width :")
  136. inputW = read()
  137. end
  138. width = tonumber(inputW)
  139.  
  140. if  GetResources() and TurtleReFuel() then
  141.     MoveIt()
  142.     for j=1,width do
  143.         for i=1,length-1 do      
  144.                 MoveBack()                               
  145.                     while ResourcesAmount==0 do
  146.                         print("add more resources to continue! y/n")
  147.                         local ans = read()
  148.                             if ans=="y" then
  149.                                 lastslotValid=1
  150.                                 NextSelect()
  151.                                 elseif ans=="n" then
  152.                                 print("Goodbye")
  153.                                 return
  154.                             end
  155.                             turtle.place()
  156.                             i=i-1
  157.                     end        
  158.         end
  159.         if Moveto =="r"  then
  160.             MoveItleft()
  161.             else
  162.             MoveItRight()
  163.         end    
  164.         if Moveto =="r"  then
  165.             Moveto = "l"
  166.             else                                   
  167.             Moveto = "r"                               
  168.         end                
  169.     end
  170.     backtoYou()
  171.  
  172. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement