Advertisement
MadScience2728

MASTER

Jan 11th, 2014
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.58 KB | None | 0 0
  1. --[[
  2. Changes:
  3. Turtles no longer monitor how many rows they've gone forward (no more rowsProgressed file)
  4. Master turtle simply waits for (numberSlaves) unique turtles to send messages saying
  5. they are ready and waiting. Slave turtles repeatedly send ready and waiting signals to prevent
  6. the sync problems we were having before.
  7. --]]
  8.  
  9. -- Number of neighbouring turtles
  10. numberSlaves = 15
  11.  
  12. -- Open up modem to receive wireless broadcasts
  13. rednet.open("right")
  14.  
  15. -- Wait until neighbouring turtles are ready
  16. function waitForSlaves()
  17.   local IDsOfWaitingTurtles = {}
  18.   local remoteTurtleID, rednetMessage
  19.   local newTurtleIsReportingReady
  20.  
  21.   -- Wait for (numberNeighbours) unique turtles to send ready messages
  22.   repeat
  23.     remoteTurtleID, rednetMessage, _ = rednet.receive()
  24.    
  25.     if rednetMessage == "I am ready and waiting master" then
  26.       -- Check if turtle has replied already
  27.       newTurtleIsReportingReady = true
  28.  
  29.       for i=1, table.getn(IDsOfWaitingTurtles) do
  30.         if remoteTurtleID == IDsOfWaitingTurtles[i] then
  31.           newTurtleIsReportingReady = false
  32.           break
  33.         end
  34.       end
  35.  
  36.       if newTurtleIsReportingReady then
  37.         table.insert(IDsOfWaitingTurtles, remoteTurtleID)
  38.       end
  39.     end
  40.   until table.getn(IDsOfWaitingTurtles) >= numberSlaves
  41.  
  42.   rednet.broadcast("You are authorised to proceed")
  43. end
  44.  
  45. bool=true
  46.  
  47. while bool==true do
  48.   if rs.getInput("back", true) then
  49.       print ("Waiting")
  50.       sleep (1)
  51.   else
  52.     print ("Let's Roll!")
  53.     bool=false
  54.   end
  55. end
  56.  
  57. X=66
  58.  
  59. print ("Startup Functions Activating")
  60. print ("Going to lowest point")
  61.  
  62. turtle.select(3)
  63. turtle.back()
  64.  
  65. while true do
  66.   local mobsPresent = turtle.attackDown()
  67.   local digSuccess = turtle.digDown()
  68.   local movementSuccess = turtle.down()
  69.  
  70.   if not mobsPresent and not digSuccess and not movementSuccess then
  71.     break
  72.   end
  73. end
  74.  
  75. for b = 1, X do
  76.   turtle.digUp()
  77.     while not turtle.up() do
  78.       turtle.attackUp()
  79.     end
  80.   end
  81.  
  82.   print ("Calibrated level for a flat bedrock world.")
  83.   print ("---------------------------")
  84.   print ("Starting World Eating Scripts!")
  85.   print ("---------------------------")
  86.  
  87.   turtle.dig()
  88.  
  89.   while not turtle.forward() do
  90.     turtle.attack()
  91.   end
  92.  
  93.   while true do
  94.  
  95.     for i = 1, 2 do
  96.  
  97.       for c = 1, X do
  98.         turtle.dig()
  99.         turtle.digDown()
  100.         while not turtle.down() do
  101.           turtle.attackDown()
  102.         end
  103.       end
  104.  
  105.       for d = 1, X do
  106.         turtle.dig()
  107.         turtle.digUp()
  108.         while not turtle.up() do
  109.           turtle.attackUp()
  110.         end
  111.       end
  112.  
  113.       for r = 1, 2 do
  114.         turtle.dig()
  115.         while not turtle.forward() do
  116.           turtle.attack()
  117.         end
  118.  
  119.       end
  120.  
  121.       Fuel = turtle.getFuelLevel()
  122.  
  123.       print ("Fuel level is: "..Fuel)
  124.  
  125.       if Fuel >= 8192 then
  126.  
  127.         print ("Fuel level is above minimum safe limit.")
  128.  
  129.       else
  130.  
  131.         print ("Fuel is below safe limit! Refueling!")
  132.  
  133.         turtle.select(2)
  134.         turtle.place()
  135.         turtle.suck()
  136.         turtle.refuel()
  137.         turtle.dig()
  138.        
  139.         turtle.select(3)
  140.          
  141.     end
  142.  
  143.     print ("Dropping off items")
  144.  
  145.         turtle.dig()
  146.         turtle.attack()
  147.      
  148.  
  149.     turtle.select(1)
  150.     while not turtle.place() do
  151.       turtle.select(3)
  152.       turtle.attack()
  153.       turtle.select(1)
  154.     end
  155.  
  156.     for dropslot = 3, 16 do
  157.       turtle.select(dropslot)
  158.       turtle.drop()
  159.     end
  160.  
  161.     waitForSlaves()
  162.  
  163.     turtle.select(1)
  164.  
  165.     turtle.dig()
  166.  
  167.     turtle.select(3)
  168.  
  169.   end
  170. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement