View difference between Paste ID: CpmzLYpM and kUgDdQ61
SHOW: | | - or go back to the newest paste.
1
    rednet.open("right")
2
    local func
3
    local tArgs = {...}
4
     
5
    function cleanup()
6
       for i = 1,12 do
7
          turtle.select(i)
8
          turtle.dropDown()
9
       end
10
    end
11
     
12
    function place()
13
       turtle.select(16)
14
       turtle.place()
15
       turtle.down()
16
       turtle.select(15)
17
       turtle.place()
18
       turtle.select(14)
19
       turtle.placeDown()
20
    end
21
	
22
    function placePower()
23
       turtle.select(1)
24
       turtle.place()
25
       turtle.down()
26
       turtle.select(2)
27
       turtle.place()
28
       turtle.attack()
29
    end
30
	
31
    function removePower()
32
       turtle.select(2)
33
       turtle.dig()
34
       turtle.up()
35
       turtle.select(1)
36
       turtle.dig()
37
       turtle.forward()
38
    end
39
     
40
    function remove()
41
       turtle.select(14)
42
       turtle.digDown()
43
       turtle.select(15)
44
       turtle.dig()
45
       turtle.up()
46
       turtle.select(16)
47
       turtle.dig()
48
    end
49
     
50
    function fuel()
51
       turtle.select(13)
52
       turtle.placeUp()
53
       turtle.select(1)
54
       turtle.suckUp()
55
       turtle.dropUp(turtle.getItemCount(1) - 4)
56
       turtle.refuel()
57
       turtle.select(13)
58
       turtle.digUp()
59
    end
60
     
61
    function fuelBoss(powerStation)
62
      turtle.select(13)
63
      turtle.placeUp()
64
      turtle.select(1)
65
      turtle.suckUp()
66
      turtle.dropUp(doMath(powerStation))
67
      turtle.select(13)
68
      turtle.digUp()
69
      turtle.up()
70
      for x,y in pairs(powerStation) do
71
        if (type(y) ~= "table") and (y ~= nil) then
72
	  turtle.turnLeft()
73
	  turtle.drop(4)
74
	  turtle.turnRight()
75
	else
76
          for w,z in pairs(y) do
77
	    turtle.forward()
78
            turtle.turnRight()
79
            turtle.forward(z+1)
80
	    turtle.turnRight()
81
	    turtle.drop(4)
82
	    turtle.turnRight()
83
	    turtle.forward(z+1)
84
	    turtle.turnRight()
85
	  end
86
        end
87
      end
88
    end
89
90
    function doMath(tbl)
91
      y = table.getn(tbl) + table.getn(tbl[2])
92
      if tbl[2] ~= nil then
93
        y=y-1
94
      end
95
      y=4*y
96
      return y
97
    end
98
	 
99
    function checkFuel()
100
       if turtle.getFuelLevel() < 600 then
101
          fuel()
102
       end
103
    end
104
	
105
    function checkStationFuel(id)
106
      if turtle.getFuelLevel() < 600 then
107
        rednet.send("true", id)
108
      else
109
        rednet.send("false", id)
110
      end
111
    end
112
113
    function eatFuel()
114
      turtle.select(3)
115
      turtle.refuel()
116
      turtle.select(1)
117
    end
118
	
119
    function cycle()
120
       place()
121
       sleep(25)
122
       while turtle.getItemCount(1) > 0 do
123
          cleanup()
124
          sleep(2)
125
       end
126
       remove()
127
       checkFuel()
128
       turtle.forward()
129
    end
130
     
131
    function checkIn(fromID)
132
       rednet.send(fromID, tArgs[1])
133
    end
134
     
135
    function chunkLoad()
136
       turtle.select(16)
137
       turtle.digUp()
138
       checkFuel()
139
       turtle.select(16)
140
       turtle.forward()
141
       turtle.placeUp()
142
    end
143
     
144
    while true do
145
       local id,msg,dist = rednet.receive()
146
       func = loadstring(msg)
147
       setfenv(func, getfenv())
148
       func(id)
149
       rednet.send(id,"Done")
150
    end