SHOW:
|
|
- or go back to the newest paste.
1 | - | subCoordX = 3091 |
1 | + | subCoordX = 11921 |
2 | - | subCoordY = 66 |
2 | + | subCoordY = 67 |
3 | - | subCoordZ = 1391 |
3 | + | subCoordZ = 6070 |
4 | maxDist = 5000 | |
5 | - | remMissile = 4 |
5 | + | remMissile = 2 |
6 | ||
7 | function clear() | |
8 | term.clear() | |
9 | term.setCursorPos(1, 1) | |
10 | - | term.write(" Raketnym kompleksom \"P-6\"") |
10 | + | term.write(" Raketnym kompleksom \"P-2\"") |
11 | end | |
12 | ||
13 | function insertCoords() | |
14 | while true do | |
15 | clear() | |
16 | print("\n\nVstavit' koordinaty:") | |
17 | term.setCursorPos(1, 6) | |
18 | term.write("X: ") | |
19 | term.setCursorPos(1, 8) | |
20 | term.write("Z: ") | |
21 | term.setCursorPos(1, 10) | |
22 | term.write("Radius: ") | |
23 | term.setCursorPos(4, 6) | |
24 | x = read() | |
25 | term.setCursorPos(4, 8) | |
26 | z = read() | |
27 | term.setCursorPos(9, 10) | |
28 | radius = read() | |
29 | radius = math.max(1, radius) | |
30 | radius = math.min(4, radius) | |
31 | ||
32 | term.setCursorPos(1, 12) | |
33 | ||
34 | if tonumber(x) ~= nil and tonumber(z) ~= nil and tonumber(radius) ~= nil then | |
35 | print("Sokhranennyye koordinaty.") | |
36 | break | |
37 | end | |
38 | end | |
39 | ||
40 | sleep(1) | |
41 | clear() | |
42 | end | |
43 | ||
44 | function drawRosace() | |
45 | term.setCursorPos(21, 6) | |
46 | term.write(" | ") | |
47 | term.setCursorPos(21, 7) | |
48 | term.write(" | ") | |
49 | term.setCursorPos(21, 8) | |
50 | term.write(" /|\\ ") | |
51 | term.setCursorPos(21, 9) | |
52 | term.write(" / | \\ ") | |
53 | term.setCursorPos(21, 10) | |
54 | term.write("----O----") | |
55 | term.setCursorPos(21, 11) | |
56 | term.write(" \\ | / ") | |
57 | term.setCursorPos(21, 12) | |
58 | term.write(" \\|/ ") | |
59 | term.setCursorPos(21, 13) | |
60 | term.write(" | ") | |
61 | term.setCursorPos(21, 14) | |
62 | term.write(" | ") | |
63 | end | |
64 | ||
65 | function getRemainingMissile() | |
66 | term.setCursorPos(1, 19) | |
67 | - | if remMissile == 4 then |
67 | + | if remMissile == 2 then |
68 | - | term.write("Raketa: [1] [2] [3] [4] ") |
68 | + | term.write("Raketa: [2] [1] ") |
69 | - | elseif remMissile == 3 then |
69 | + | |
70 | - | term.write("Raketa: [ ] [2] [3] [4] ") |
70 | + | term.write("Raketa: [ ] [1] ") |
71 | - | elseif remMissile == 2 then |
71 | + | |
72 | - | term.write("Raketa: [ ] [ ] [3] [4] ") |
72 | + | term.write("Raketa: [ ] [ ] ") |
73 | end | |
74 | - | term.write("Raketa: [ ] [ ] [ ] [4] ") |
74 | + | |
75 | ||
76 | - | term.write("Raketa: [ ] [ ] [ ] [ ] ") |
76 | + | |
77 | p = peripheral.wrap("bottom") | |
78 | w = p.getWorld(0) | |
79 | y = 128 | |
80 | id = 0 | |
81 | while id == 0 do | |
82 | id = w.getBlockID(coordx, y, coordz) | |
83 | y = y-1 | |
84 | if y < 10 then | |
85 | clear() | |
86 | print("\n\nZapusk rakety ne udaslya!!!!") | |
87 | sleep(1) | |
88 | os.reboot() | |
89 | end | |
90 | end | |
91 | clear() | |
92 | w.playSound("AdvJetpacks_startup", coordx, y, coordz, 1, 0.2) | |
93 | print("\n\nZapusk krylatyye rakety!") | |
94 | rs.setOutput("bottom", true) | |
95 | sleep(0.5) | |
96 | rs.setOutput("bottom", false) | |
97 | sleep(1) | |
98 | - | rs.setOutput("left", true) |
98 | + | |
99 | sleep(2) | |
100 | - | rs.setOutput("left", false) |
100 | + | |
101 | spawnMissile(coordx, coordz, radius) | |
102 | end | |
103 | ||
104 | function spawnMissile(coordX, coordZ, size) | |
105 | p = peripheral.wrap("bottom") | |
106 | w = p.getWorld(0) | |
107 | abort = false | |
108 | xt = 0 -- current position; x | |
109 | zt = 0 -- / current position; y | |
110 | d = 0 -- current direction; 0=RIGHT, 1=DOWN, 2=LEFT, 3=UP | |
111 | s = 1 -- chain size | |
112 | ||
113 | k=1 | |
114 | while k <= size-1 do | |
115 | k = k+1 | |
116 | m = 0 | |
117 | if k < size-1 then | |
118 | m = 2 | |
119 | else | |
120 | m = 3 | |
121 | end | |
122 | j = 0 | |
123 | while j<m do | |
124 | j=j+1 | |
125 | i=0 | |
126 | while i<s do | |
127 | i=i+1 | |
128 | --std::cout << matrix[x][y] << " "; | |
129 | --print("X: " .. coordX+xt .. " Z: " .. coordZ+zt) | |
130 | id = w.getBlockID(coordX+xt, y, coordZ+zt) | |
131 | if id == 8 or id == 9 then | |
132 | abort = true | |
133 | break | |
134 | end | |
135 | ||
136 | spawnGas(coordX+xt, coordZ+zt) | |
137 | ||
138 | if d == 0 then zt = zt + 2 | |
139 | elseif d == 1 then xt = xt + 2 | |
140 | elseif d == 2 then zt = zt - 2 | |
141 | elseif d == 3 then xt = xt - 2 | |
142 | end | |
143 | end | |
144 | if abort == true then | |
145 | break | |
146 | end | |
147 | d = (d+1)%4 | |
148 | end | |
149 | if abort == true then | |
150 | break | |
151 | end | |
152 | s = s + 1 | |
153 | end | |
154 | ||
155 | w.setBlock(coordX, y+1, coordZ, 76, 0) | |
156 | end | |
157 | ||
158 | function spawnGas(x, z) | |
159 | w.setBlock(x, y, z, 1, 0) | |
160 | w.setBlock(x, y+2, z, 929, 0) | |
161 | --w.setBlock(x, y+1, z, 76, 0) | |
162 | end | |
163 | ||
164 | function validateCodes() | |
165 | while true do | |
166 | error = 0 | |
167 | clear() | |
168 | print("\n\nKod autentifikatsii:") | |
169 | term.setCursorPos(1, 6) | |
170 | term.write("CDR:") | |
171 | term.setCursorPos(1, 8) | |
172 | term.write("XO:") | |
173 | term.setCursorPos(6, 6) | |
174 | code1 = read() | |
175 | term.setCursorPos(6, 8) | |
176 | code2 = read() | |
177 | term.setCursorPos(1, 10) | |
178 | ||
179 | ||
180 | if tonumber(code1) ~= nil and tonumber(code2) ~= nil then | |
181 | rest = http.get("http://172.16.20.220/luanet/servlets/ssg/s200.php?code1="..code1.."&code2="..code2) | |
182 | reply = rest.readAll() | |
183 | rest.close() | |
184 | ||
185 | - | rest = http.get("http://172.16.20.220/luanet/servlets/ssg/k77.php?code1="..code1.."&code2="..code2) |
185 | + | |
186 | print("Zapusk razreshen.") | |
187 | launchMissile(x, z, radius) | |
188 | break | |
189 | else | |
190 | term.setCursorPos(1,15) | |
191 | term.write("Oshibka! Nevernyy kod!") | |
192 | error = error + 1 | |
193 | if error > 3 then | |
194 | os.reboot() | |
195 | end | |
196 | sleep(1) | |
197 | term.setCursorPos(1,15) | |
198 | term.write(" ") | |
199 | end | |
200 | end | |
201 | end | |
202 | ||
203 | sleep(1) | |
204 | clear() | |
205 | end | |
206 | ||
207 | function shootMissile() | |
208 | if remMissile > 0 then | |
209 | validateCodes() | |
210 | --launchMissile(x, z, radius) | |
211 | remMissile = remMissile - 1 | |
212 | return true | |
213 | else | |
214 | return false | |
215 | end | |
216 | end | |
217 | ||
218 | function autoAcquire() | |
219 | p = peripheral.wrap("bottom") | |
220 | ||
221 | while true do | |
222 | clear() | |
223 | print("\n\nTsel:'") | |
224 | term.setCursorPos(1, 6) | |
225 | term.write("Imya pol'zovatelya: ") | |
226 | term.setCursorPos(1, 9) | |
227 | term.write("Sila: ") | |
228 | ||
229 | term.setCursorPos(1, 7) | |
230 | user = read() | |
231 | term.setCursorPos(7, 9) | |
232 | radius = read() | |
233 | radius = math.max(1, radius) | |
234 | radius = math.min(8, radius) | |
235 | ||
236 | pl = p.getPlayerByName(user) | |
237 | term.setCursorPos(1, 12) | |
238 | ||
239 | if pl ~= nil and tonumber(radius) ~= nil then | |
240 | ent = pl.asEntity() | |
241 | x, ignoredY, z = ent.getPosition() | |
242 | print("Tsel' dostignuta.") | |
243 | break | |
244 | end | |
245 | end | |
246 | ||
247 | sleep(1) | |
248 | clear() | |
249 | end | |
250 | ||
251 | ||
252 | x = 75 | |
253 | z = 900 | |
254 | radius = 4 | |
255 | ||
256 | clear() | |
257 | while true do | |
258 | getRemainingMissile() | |
259 | drawRosace() | |
260 | term.setCursorPos(1, 3) | |
261 | term.write(" ") | |
262 | term.setCursorPos(1, 3) | |
263 | term.write("X: " .. x) | |
264 | term.setCursorPos(1, 4) | |
265 | term.write(" ") | |
266 | term.setCursorPos(1, 4) | |
267 | term.write("Z: " .. z) | |
268 | term.setCursorPos(1, 5) | |
269 | ||
270 | d = math.floor(math.sqrt(((x - subCoordX) ^ 2) + ((z - subCoordZ) ^ 2))) / 1000 | |
271 | ||
272 | term.write("d: " .. d .. " km ") | |
273 | local event, key = os.pullEvent("key") | |
274 | if key == 200 then | |
275 | z = z + 1 | |
276 | elseif key == 208 then | |
277 | z = z - 1 | |
278 | elseif key == 203 then | |
279 | x = x - 1 | |
280 | elseif key == 205 then | |
281 | x = x + 1 | |
282 | elseif key == 211 then | |
283 | if d < maxDist then | |
284 | shootMissile() | |
285 | else | |
286 | clear() | |
287 | term.setCursorPos(1, 12) | |
288 | print("Tsel' slishkom daleko.") | |
289 | sleep(2) | |
290 | clear() | |
291 | end | |
292 | elseif key == 210 then | |
293 | insertCoords() | |
294 | elseif key == 199 then | |
295 | autoAcquire() | |
296 | end | |
297 | end |