Advertisement
Guest User

Main

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