Advertisement
MadScience2728

SLAVE_BETA

Jan 11th, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.35 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 (numberNeighbours) 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. -- Open up modem to receive wireless broadcasts
  10. rednet.open("right")
  11.  
  12. -- Wait until neighbouring turtles are ready
  13. function waitForMaster()
  14.   local event, param1, param2
  15.  
  16.   rednet.broadcast("I am ready and waiting master")
  17.   os.startTimer(1)
  18.  
  19.   while true do
  20.     event, param1, param2 = os.pullEvent()
  21.  
  22.     -- Resend ready message every second, in case master is not yet ready
  23.     if event == "timer" then
  24.       rednet.broadcast("I am ready and waiting master")
  25.       os.startTimer(1)
  26.    
  27.     -- Wait for master turtle to give the OK to proceed before continuing digging
  28.     elseif event == "rednet_message" then
  29.       local message = param2
  30.       if message == "You are authorised to proceed" then
  31.         break
  32.       end -- if message
  33.     end -- if event
  34.   end -- while
  35. end -- function
  36.  
  37. bool=true
  38.  
  39. while bool==true do
  40.   if rs.getInput("back", true) then
  41.       print ("Waiting")
  42.       sleep (1)
  43.   else
  44.     print ("Let's Roll!")
  45.     bool=false
  46.   end
  47. end
  48.  
  49. X=3
  50.  
  51. print ("Startup Functions Activating")
  52. print ("Going to lowest point")
  53.  
  54. turtle.select(4)
  55. turtle.back()
  56.  
  57. while true do
  58.   local mobsPresent = turtle.attackDown()
  59.   local digSuccess = turtle.digDown()
  60.   local movementSuccess = turtle.down()
  61.  
  62.   if not mobsPresent and not digSuccess and not movementSuccess then
  63.     break
  64.   end
  65. end
  66.  
  67. for b = 1, X do
  68.   turtle.digUp()
  69.     while not turtle.up() do
  70.       turtle.attackUp()
  71.     end
  72.   end
  73.  
  74.   print ("Calibrated level for a flat bedrock world.")
  75.   print ("---------------------------")
  76.   print ("Starting World Eating Scripts!")
  77.   print ("---------------------------")
  78.  
  79.   turtle.dig()
  80.  
  81.   while not turtle.forward() do
  82.     turtle.attack()
  83.   end
  84.  
  85.   while true do
  86.  
  87.     for i = 1, 2 do
  88.  
  89.       for c = 1, X do
  90.         turtle.dig()
  91.         turtle.digDown()
  92.         while not turtle.down() do
  93.           turtle.attackDown()
  94.         end
  95.       end
  96.  
  97.       for d = 1, X do
  98.         turtle.dig()
  99.         turtle.digUp()
  100.         while not turtle.up() do
  101.           turtle.attackUp()
  102.         end
  103.       end
  104.  
  105.       for r = 1, 2 do
  106.         turtle.dig()
  107.         while not turtle.forward() do
  108.           turtle.attack()
  109.         end
  110.  
  111.       end
  112.  
  113.       Fuel = turtle.getFuelLevel()
  114.  
  115.       print ("Fuel level is: "..Fuel)
  116.  
  117.       if Fuel >= 8192 then
  118.  
  119.         print ("Fuel level is above minimum safe limit.")
  120.  
  121.       else
  122.  
  123.         print ("Fuel is below safe limit! Refueling!")
  124.  
  125.         turtle.select(3)
  126.         turtle.place()
  127.         turtle.suck()
  128.         turtle.refuel()
  129.         turtle.dig()
  130.        
  131.         turtle.select(4)
  132.          
  133.     end
  134.  
  135.     print ("Dropping off items")
  136.  
  137.     turtle.dig()
  138.     turtle.attack()
  139.    
  140.     turtle.select(2)
  141.     while not turtle.place() do
  142.       turtle.select(4)
  143.       turtle.attack()
  144.       turtle.select(2)
  145.     end
  146.  
  147.     for dropslot = 4, 16 do
  148.       turtle.select(dropslot)
  149.       turtle.drop()
  150.     end
  151.  
  152.     waitForMaster()
  153.  
  154.     turtle.select(2)
  155.  
  156.     turtle.dig()
  157.  
  158.     turtle.select(4)
  159.  
  160.   end
  161. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement