Guest User

Slave Ore Finder 1

a guest
Jan 17th, 2014
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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=66
  50.  
  51. print ("Startup Functions Activating")
  52. print ("Going to lowest point")
  53.  
  54. turtle.select(1)
  55. turtle.dig()
  56. turtle.select(3)
  57. turtle.back()
  58.  
  59. while true do
  60.   local mobsPresent = turtle.attackDown()
  61.   local digSuccess = turtle.digDown()
  62.   local movementSuccess = turtle.down()
  63.  
  64.   if not mobsPresent and not digSuccess and not movementSuccess then
  65.     break
  66.   end
  67. end
  68.  
  69. for b = 1, X do
  70.   turtle.digUp()
  71.     while not turtle.up() do
  72.       turtle.attackUp()
  73.     end
  74.   end
  75.  
  76.   print ("---------------------------")
  77.   print ("Starting World Eating Scripts!")
  78.   print ("---------------------------")
  79.  
  80.   turtle.dig()
  81.  
  82.   while not turtle.forward() do
  83.     turtle.attack()
  84.   end
  85.  
  86.   while true do
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93. ore = false
  94.  
  95.    
  96.  
  97.       for c = 1, X do
  98.     turtle.select(2)
  99.     ore = turtle.compareDown()
  100.     if ore == true then
  101.  
  102.         for t = 1, c do
  103.             turtle.digUp()
  104.             while not turtle.up()
  105.                 turtle.digUp()
  106.                 turtle.attackUp()
  107.             end
  108.         end
  109.     else
  110.  
  111.         turtle.dig()
  112.         turtle.digDown()
  113.              while not turtle.down() do
  114.                 turtle.attackDown()
  115.              end
  116.     end
  117.       end
  118.  
  119. if ore == false then
  120.       for d = 1, X do
  121.         turtle.dig()
  122.         turtle.digUp()
  123.         while not turtle.up() do
  124.           turtle.attackUp()
  125.         end
  126. else
  127. end
  128.    
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.       for r = 1, 2 do
  139.         turtle.dig()
  140.         while not turtle.forward() do
  141.           turtle.attack()
  142.         end
  143.  
  144.       end
  145.  
  146.     print ("Dropping off items")
  147.  
  148.         turtle.dig()
  149.         turtle.attack()
  150.      
  151.  
  152.     turtle.select(1)
  153.     while not turtle.place() do
  154.       turtle.select(3)
  155.       turtle.attack()
  156.       turtle.select(1)
  157.     end
  158.  
  159.     for dropslot = 3, 16 do
  160.       turtle.select(dropslot)
  161.       turtle.drop()
  162.     end
  163.  
  164.     waitForMaster()
  165.  
  166.     turtle.select(1)
  167.  
  168.     turtle.dig()
  169.  
  170.     turtle.select(3)
  171.  
  172.   end
  173. end
Advertisement
Add Comment
Please, Sign In to add comment