SHOW:
|
|
- or go back to the newest paste.
1 | function DROP(dropslot, top_bottom) | |
2 | - | turtle.select(dropslot) |
2 | + | turtle.select(dropslot) |
3 | if top_bottom == 1 then | |
4 | - | turtle.dropUp(1) |
4 | + | turtle.dropUp(1) |
5 | else | |
6 | - | turtle.dropDown(1) |
6 | + | turtle.dropDown(1) |
7 | end | |
8 | end | |
9 | function SUCK(top_bottom) | |
10 | - | for slot=1,4 do |
10 | + | for slot=1,4 do |
11 | - | turtle.select(slot) |
11 | + | turtle.select(slot) |
12 | - | if top_bottom == 1 then |
12 | + | |
13 | - | turtle.suckUp() |
13 | + | turtle.suckUp() |
14 | - | else |
14 | + | |
15 | - | turtle.suckDown() |
15 | + | turtle.suckDown() |
16 | - | end |
16 | + | |
17 | end | |
18 | end | |
19 | function GET_RID_OF() | |
20 | - | turtle.select(4) |
20 | + | turtle.select(4) |
21 | - | turtle.drop() |
21 | + | turtle.drop() |
22 | end | |
23 | function GET_NEW() | |
24 | - | turtle.select(4) |
24 | + | turtle.select(4) |
25 | - | turtle.suck(6) |
25 | + | turtle.suck(6) |
26 | end | |
27 | function INSERT(top_bottom) | |
28 | - | for line=1,2 do |
28 | + | for line=1,2 do |
29 | - | for pattern=1,3 do |
29 | + | for pattern=1,3 do |
30 | - | for slot=1,3 do |
30 | + | for slot=1,3 do |
31 | - | DROP(slot, top_bottom) |
31 | + | DROP(slot, top_bottom) |
32 | - | end |
32 | + | end |
33 | - | end |
33 | + | |
34 | - | for pattern=1,3 do |
34 | + | for pattern=1,3 do |
35 | - | DROP(2, top_bottom) |
35 | + | DROP(2, top_bottom) |
36 | - | DROP(4, top_bottom) |
36 | + | DROP(4, top_bottom) |
37 | - | DROP(2, top_bottom) |
37 | + | DROP(2, top_bottom) |
38 | - | end |
38 | + | |
39 | - | for pattern=1,3 do |
39 | + | for pattern=1,3 do |
40 | - | for slot=1,3 do |
40 | + | for slot=1,3 do |
41 | - | DROP(4-slot, top_bottom) |
41 | + | DROP(4-slot, top_bottom) |
42 | - | end |
42 | + | end |
43 | - | end |
43 | + | |
44 | end | |
45 | end | |
46 | function GET_TO(reactornum) | |
47 | turtle.up() | |
48 | local temp = math.ceil(reactornum/6)-1 | |
49 | if temp ~= 0 then | |
50 | for i=0,temp do | |
51 | - | if ( reactornum == 1 ) or ( reactornum == 4 ) then |
51 | + | for j=1,5 do |
52 | - | turtle.turnRight() |
52 | + | |
53 | - | for xtoreac=1,4 do |
53 | + | end |
54 | - | turtle.forward() |
54 | + | |
55 | - | end |
55 | + | end |
56 | - | turtle.turnLeft() |
56 | + | for i=1,3 do |
57 | turtle.forward() | |
58 | - | if ( reactornum == 3 ) or ( reactornum == 6 ) then |
58 | + | end |
59 | - | turtle.turnLeft() |
59 | + | if ( reactornum%6 == 1 ) or ( reactornum%6 == 4 ) then |
60 | - | for xtoreactor=1,4 do |
60 | + | turtle.turnRight() |
61 | - | turtle.forward() |
61 | + | for xtoreac=1,4 do |
62 | - | end |
62 | + | turtle.forward() |
63 | - | turtle.turnRight() |
63 | + | |
64 | - | end |
64 | + | |
65 | else | |
66 | if ( reactornum%6 == 3 ) or ( reactornum%6 == 0 ) then | |
67 | turtle.turnLeft() | |
68 | - | if reactornum <= 3 then |
68 | + | for xtoreactor=1,4 do |
69 | turtle.forward() | |
70 | - | SUCK(0) |
70 | + | end |
71 | turtle.turnRight() | |
72 | end | |
73 | end | |
74 | - | SUCK(1) |
74 | + | |
75 | function GET_REACTOR(reactornum) | |
76 | if ( reactornum%6 <= 3 ) and ( reactornum%6 ~= 0 ) then | |
77 | turtle.down() | |
78 | SUCK(0) | |
79 | - | if reactornum <=3 then |
79 | + | |
80 | else | |
81 | - | INSERT(0) |
81 | + | |
82 | SUCK(1) | |
83 | turtle.down() | |
84 | end | |
85 | - | INSERT(1) |
85 | + | |
86 | function PUT_REACTOR(reactornum) | |
87 | if ( reactornum%6 <= 3 ) and ( reactornum%6 ~= 0 ) then | |
88 | turtle.down() | |
89 | INSERT(0) | |
90 | - | if ( reactornum == 1 ) or ( reactornum == 4 ) then |
90 | + | |
91 | - | turtle.turnLeft() |
91 | + | else |
92 | - | for i=1,4 do |
92 | + | |
93 | - | turtle.forward() |
93 | + | INSERT(1) |
94 | - | end |
94 | + | |
95 | - | turtle.turnLeft() |
95 | + | end |
96 | end | |
97 | - | if ( reactornum == 3 ) or ( reactornum == 6 ) then |
97 | + | |
98 | - | turtle.turnRight() |
98 | + | if ( reactornum%6 == 1 ) or ( reactornum%6 == 4 ) then |
99 | - | for i=1,4 do |
99 | + | |
100 | - | turtle.forward() |
100 | + | for i=1,4 do |
101 | - | end |
101 | + | turtle.forward() |
102 | - | turtle.turnRight() |
102 | + | |
103 | - | else |
103 | + | |
104 | - | turtle.turnLeft() |
104 | + | else |
105 | - | turtle.turnLeft() |
105 | + | if ( reactornum%6 == 3 ) or ( reactornum%6 == 0 ) then |
106 | - | end |
106 | + | turtle.turnRight() |
107 | for i=1,4 do | |
108 | turtle.forward() | |
109 | end | |
110 | turtle.turnRight() | |
111 | else | |
112 | turtle.turnLeft() | |
113 | turtle.turnLeft() | |
114 | end | |
115 | end | |
116 | - | local Fuel = true |
116 | + | for i=1,3 do |
117 | - | GET_TO(reactornum) |
117 | + | |
118 | - | GET_REACTOR(reactornum) |
118 | + | end |
119 | - | GET_BACK(reactornum) |
119 | + | local temp = math.ceil(reactornum/6)-1 |
120 | if temp ~= 0 then | |
121 | - | GET_RID_OF() |
121 | + | for i=0,temp do |
122 | for j=1,5 do | |
123 | - | GET_NEW() |
123 | + | |
124 | end | |
125 | - | while Fuel do |
125 | + | |
126 | - | if turtle.getFuelLevel() < 1000 then |
126 | + | end |
127 | - | turtle.select(16) |
127 | + | turtle.down() |
128 | - | turtle.suck(1) |
128 | + | turtle.turnLeft() |
129 | - | turtle.drop() |
129 | + | turtle.turnLeft() |
130 | - | else |
130 | + | |
131 | - | Fuel = false |
131 | + | |
132 | - | end |
132 | + | local ReacFuel=0 |
133 | local Fuel = true | |
134 | GET_TO(reactornum) | |
135 | - | GET_TO(reactornum) |
135 | + | GET_REACTOR(reactornum) |
136 | - | PUT_REACTOR(reactornum) |
136 | + | GET_BACK(reactornum) |
137 | - | GET_BACK(reactornum) |
137 | + | turtle.turnLeft() |
138 | - | end |
138 | + | GET_RID_OF() |
139 | - | REACTOR_RENEW(2) |
139 | + | turtle.turnLeft() |
140 | GET_NEW() | |
141 | if turtle.getItemDetail(4).name == "ic2:quad_mox_fuel_rod" then | |
142 | ReacFuel=1 | |
143 | else | |
144 | if turtle.getItemDetail(4).name == "ic2:quad_uranium_fuel_rod" then | |
145 | ReacFuel=2 | |
146 | end | |
147 | end | |
148 | turtle.turnLeft() | |
149 | while Fuel do | |
150 | if turtle.getFuelLevel() < 1000 then | |
151 | turtle.select(16) | |
152 | turtle.suck(1) | |
153 | turtle.drop() | |
154 | else | |
155 | Fuel = false | |
156 | end | |
157 | end | |
158 | turtle.turnLeft() | |
159 | GET_TO(reactornum) | |
160 | PUT_REACTOR(reactornum) | |
161 | GET_BACK(reactornum) | |
162 | return ReacFuel | |
163 | end | |
164 | while true do | |
165 | local ReacFuel=0 | |
166 | local Table = {0} | |
167 | print(Table[1]) | |
168 | if fs.exists("disk/turt_ask") then | |
169 | TurtAsk = fs.open("disk/turt_ask", "r") | |
170 | Table[1] = tonumber(TurtAsk.readLine()) | |
171 | TurtAsk.close() | |
172 | if Table[1] ~= 0 then | |
173 | TurtAsk = fs.open("disk/turt_ask", "r") | |
174 | Table[1] = tonumber(TurtAsk.readLine()) | |
175 | for i=1,Table[1] do | |
176 | table.insert(Table, tonumber(TurtAsk.readLine())) | |
177 | end | |
178 | TurtAsk.close() | |
179 | TurtState = fs.open("disk/turt_state", "w") | |
180 | TurtState.writeLine(1) | |
181 | TurtState.close() | |
182 | end | |
183 | else | |
184 | sleep(10) | |
185 | end | |
186 | if Table[1] ~= 0 then | |
187 | for i=1,Table[1] do | |
188 | reactor=i+1 | |
189 | ReacFuel=REACTOR_RENEW(Table[reactor]) | |
190 | end | |
191 | else | |
192 | sleep(10) | |
193 | end | |
194 | TurtAns = fs.open("disk/turt_answer", "w") | |
195 | TurtAns.writeLine(Table[1]) | |
196 | if Table[1] ~= 0 then | |
197 | for i=1,Table[1] do | |
198 | reactor=i+1 | |
199 | TurtAns.writeLine(Table[reactor]) | |
200 | TurtAns.writeLine(0) | |
201 | TurtAns.writeLine(ReacFuel) | |
202 | end | |
203 | end | |
204 | TurtAns.close() | |
205 | if Table[1] ~= 0 then | |
206 | sleep(11) | |
207 | TurtAsk = fs.open("disk/turt_ask", "w") | |
208 | TurtAsk.writeLine(0) | |
209 | TurtAsk.close() | |
210 | TurtState = fs.open("disk/turt_state", "w") | |
211 | TurtState.writeLine(0) | |
212 | TurtState.close() | |
213 | end | |
214 | end |