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