SHOW:
|
|
- or go back to the newest paste.
1 | function clear() | |
2 | term.clear() | |
3 | term.setCursorPos(1, 1) | |
4 | term.write(" Raketnym kompleksom \"D-4\"") | |
5 | end | |
6 | ||
7 | function insertCoords() | |
8 | while true do | |
9 | clear() | |
10 | print("\n\nVstavit' koordinaty:") | |
11 | term.setCursorPos(1, 6) | |
12 | term.write("X: ") | |
13 | term.setCursorPos(1, 8) | |
14 | term.write("Z: ") | |
15 | term.setCursorPos(4, 6) | |
16 | x = read() | |
17 | term.setCursorPos(4, 8) | |
18 | z = read() | |
19 | term.setCursorPos(1, 10) | |
20 | ||
21 | if tonumber(x) ~= nil and tonumber(z) ~= nil then | |
22 | print("Sokhranennyye koordinaty.") | |
23 | break | |
24 | end | |
25 | end | |
26 | ||
27 | sleep(1) | |
28 | clear() | |
29 | end | |
30 | ||
31 | function drawRosace() | |
32 | term.setCursorPos(21, 6) | |
33 | term.write(" | ") | |
34 | term.setCursorPos(21, 7) | |
35 | term.write(" | ") | |
36 | term.setCursorPos(21, 8) | |
37 | term.write(" /|\\ ") | |
38 | term.setCursorPos(21, 9) | |
39 | term.write(" / | \\ ") | |
40 | term.setCursorPos(21, 10) | |
41 | term.write("----O----") | |
42 | term.setCursorPos(21, 11) | |
43 | term.write(" \\ | / ") | |
44 | term.setCursorPos(21, 12) | |
45 | term.write(" \\|/ ") | |
46 | term.setCursorPos(21, 13) | |
47 | term.write(" | ") | |
48 | term.setCursorPos(21, 14) | |
49 | term.write(" | ") | |
50 | end | |
51 | ||
52 | function getRemainingMissile() | |
53 | term.setCursorPos(1, 19) | |
54 | if remMissile == 3 then | |
55 | term.write("Raketa: [1] [2] [3] ") | |
56 | elseif remMissile == 2 then | |
57 | term.write("Raketa: [ ] [2] [3] ") | |
58 | elseif remMissile == 1 then | |
59 | term.write("Raketa: [ ] [ ] [3] ") | |
60 | elseif remMissile == 0 then | |
61 | term.write("Raketa: [ ] [ ] [ ] ") | |
62 | end | |
63 | end | |
64 | ||
65 | function launchMissile(coordx, coordz) | |
66 | p = peripheral.wrap("bottom") | |
67 | w = p.getWorld(0) | |
68 | y = 128 | |
69 | id = 0 | |
70 | while id == 0 do | |
71 | id = w.getBlockID(coordx, y, coordz) | |
72 | y = y-1 | |
73 | if y < 10 then | |
74 | clear() | |
75 | print("\n\nZapusk rakety ne udaslya!!!!") | |
76 | sleep(1) | |
77 | os.reboot() | |
78 | end | |
79 | end | |
80 | clear() | |
81 | w.playSound("AdvJetpacks_startup", coordx, y, coordz, 1, 0.2) | |
82 | print("\n\nZapusk ballisticheskoy rakety!") | |
83 | rs.setOutput("back", true) | |
84 | sleep(0.5) | |
85 | rs.setOutput("back", false) | |
86 | sleep(1) | |
87 | w.explode(-1869, 73, -1963, 1, false, false) | |
88 | sleep(2) | |
89 | w.setBlock(coordx, y, coordz, 1, 0) | |
90 | w.setBlock(coordx, y+2, coordz, 929, 0) | |
91 | w.setBlock(coordx+2, y+2, coordz, 929, 0) | |
92 | w.setBlock(coordx+2, y+2, coordz+2, 929, 0) | |
93 | w.setBlock(coordx, y+2, coordz, 929, 0) | |
94 | w.setBlock(coordx, y+2, coordz+2, 929, 0) | |
95 | w.setBlock(coordx, y+1, coordz, 76, 0) | |
96 | end | |
97 | ||
98 | function validateCodes() | |
99 | while true do | |
100 | error = 0 | |
101 | clear() | |
102 | print("\n\nKod autentifikatsii:") | |
103 | term.setCursorPos(1, 6) | |
104 | term.write("CDR:") | |
105 | term.setCursorPos(1, 8) | |
106 | term.write("XO:") | |
107 | term.setCursorPos(6, 6) | |
108 | code1 = read() | |
109 | term.setCursorPos(6, 8) | |
110 | code2 = read() | |
111 | term.setCursorPos(1, 10) | |
112 | ||
113 | ||
114 | if tonumber(code1) ~= nil and tonumber(code2) ~= nil then | |
115 | rest = http.get("http://172.16.20.220/luanet/servlets/ssb/k129.php?code1="..code1.."&code2="..code2) | |
116 | reply = rest.readAll() | |
117 | rest.close() | |
118 | ||
119 | if reply == "OK" then | |
120 | print("Zapusk razreshen.") | |
121 | launchMissile(x, z) | |
122 | break | |
123 | else | |
124 | term.setCursorPos(1,15) | |
125 | term.write("Oshibka! Nevernyy kod!") | |
126 | error = error + 1 | |
127 | if error > 3 then | |
128 | os.reboot() | |
129 | end | |
130 | sleep(1) | |
131 | term.setCursorPos(1,15) | |
132 | term.write(" ") | |
133 | end | |
134 | end | |
135 | end | |
136 | ||
137 | sleep(1) | |
138 | clear() | |
139 | end | |
140 | ||
141 | function shootMissile() | |
142 | if remMissile > 0 then | |
143 | validateCodes() | |
144 | launchMissile(x, z) | |
145 | remMissile = remMissile - 1 | |
146 | return true | |
147 | else | |
148 | return false | |
149 | end | |
150 | end | |
151 | ||
152 | remMissile = 3 | |
153 | x = 75 | |
154 | z = 900 | |
155 | ||
156 | xo = -1881 | |
157 | zo = -1966 | |
158 | clear() | |
159 | while true do | |
160 | getRemainingMissile() | |
161 | drawRosace() | |
162 | term.setCursorPos(1, 3) | |
163 | term.write(" ") | |
164 | term.setCursorPos(1, 3) | |
165 | term.write("X: " .. x) | |
166 | term.setCursorPos(1, 4) | |
167 | term.write(" ") | |
168 | term.setCursorPos(1, 4) | |
169 | term.write("Z: " .. z) | |
170 | term.setCursorPos(1, 5) | |
171 | ||
172 | d = math.floor(math.sqrt(((x - xo) ^ 2) + ((z - zo) ^ 2))) / 1000 | |
173 | ||
174 | term.write("d: " .. d .. " km ") | |
175 | local event, key = os.pullEvent("key") | |
176 | if key == 200 then | |
177 | z = z + 1 | |
178 | elseif key == 208 then | |
179 | z = z - 1 | |
180 | elseif key == 203 then | |
181 | x = x - 1 | |
182 | elseif key == 205 then | |
183 | x = x + 1 | |
184 | elseif key == 211 then | |
185 | shootMissile() | |
186 | elseif key == 210 then | |
187 | insertCoords() | |
188 | end | |
189 | end |