View difference between Paste ID: b8887V00 and HpxVKWV1
SHOW: | | - or go back to the newest paste.
1
rednet.open("right")
2
local miners = {}
3
local loaders = {}
4-
local fuelBosses = {}
4+
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-
      elseif msg == "fuelBoss" then
20+
21
         print("Done")
22-
         fuelBosses[#fuelBosses+1] = id
22+
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-
function checkFuel()
32+
33-
   if turtle.getFuelLevel() < 900 then
33+
34-
      rednet.send(fuelBosses[1], "fuelBoss")
34+
35
36-
      turtle.select(3)
36+
37-
      turtle.refuel()
37+
38-
      turtle.select(1)
38+
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