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