View difference between Paste ID: CNrq23px and 56jMRbLC
SHOW: | | - or go back to the newest paste.
1-
trednet.open("right")
1+
rednet.open("right")
2
local Args = {...}
3
local func
4
5
function cleanup()
6
  turtle.select(16)
7
  turtle.placeDown()
8
  for i = 1, 12 do
9
    turtle.select(i)
10
    turtle.dropDown()
11
  end
12
  turtle.digDown()
13
end
14
15
function fuel()
16
  turtle.select(15)
17
  turtle.placeDown()
18
  turtle.select(14)
19
  turtle.suckDown()
20
  turtle.dropDown(turtle.getItemCount(1) - 4)
21
  turtle.refuel()
22
  turtle.select(15)
23
  turtle.digDown()    
24
end
25
26
function checkFuel()
27
  if turtle.getFuelLevel() < 400 then
28
    fuel()
29
  end
30
end
31
32
function cycle()
33
  turtle.dig()
34
  turtle.forward()
35
  turtle.digUp()
36
  turtle.digDown()
37
  while turtle.getItemCount(1) > 20 do
38
    cleanup()
39
    sleep(2)
40
  end
41
  checkFuel()
42
end
43
44
function checkIn(fromID)
45
  rednet.send(fromID, Args[1])
46
end
47
48
while true do
49
  sleep(0)
50
  local id,msg,dist = rednet.receive()
51
    if msg == "cycle" then
52
      cycle()
53
    elseif msg == "checkIn" then
54
      checkIn()
55
    end
56
  func = loadstring(msg.."(...)")
57
  setfenv(func,getfenv())
58
  func (id)
59
  rednet.send(id,"Done")
60
end
61
if msg == "cycle" then
62
  cycle()
63
elseif msg == "checkIn" then
64
  checkIn()
65
end