Advertisement
eliminat

turtleminingbossnofuel

Aug 2nd, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. rednet.open("right")
  2. local miners = {}
  3. local loaders = {}
  4. local tArgs = {...}
  5.  
  6.  
  7. function findTurtles()
  8.    local gotMsg = true
  9.    local id, msg, dist
  10.    rednet.broadcast("checkIn")
  11.    while gotMsg do
  12.       id,msg,dist = rednet.receive(1)
  13.       if msg == "Miner" then
  14.          print(id..":"..msg)
  15.          miners[#miners+1] = id
  16.       elseif msg == "chunkloader" then
  17.          print(id..":"..msg)
  18.          loaders[#loaders+1] = id
  19.       elseif msg == "Done" then
  20.       else
  21.          print("Done")
  22.          gotMsg = false
  23.       end
  24.    end      
  25. end
  26.  
  27. function place()
  28.    turtle.select(1)
  29.    turtle.place()
  30.    turtle.down()
  31.    turtle.select(2)
  32.    turtle.place()
  33.    turtle.attack()
  34. end
  35.  
  36. function remove()
  37.    turtle.select(2)
  38.    turtle.dig()
  39.    turtle.up()
  40.    turtle.select(1)
  41.    turtle.dig()
  42. end
  43.  
  44. function minersGo()
  45.    for x,y in pairs(miners) do
  46.       rednet.send(y, "cycle")
  47.    end
  48.    place()
  49.    local total = 0
  50.    while total < #miners do
  51.       local id,msg,dist=rednet.receive()
  52.       total = total+1
  53.    end  
  54.    remove()
  55. end
  56.  
  57. function moveLoaders()
  58.    for x,y in pairs(loaders) do
  59.       rednet.send(y,"chunkLoad")
  60.       rednet.receive()
  61.       sleep(0.5)
  62.    end
  63. end
  64.  
  65. findTurtles()
  66. if tArgs[1] == nil then tArgs[1] = 1 end
  67. for i = 1,tArgs[1] do
  68.    print("Interation: "..tostring(i).." of "..tostring(tArgs[1]))
  69.    minersGo()
  70.    turtle.forward()
  71.    moveLoaders()
  72. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement