SHOW:
|
|
- or go back to the newest paste.
1 | - | --[[ opencomputers nano на русском |
1 | + | -- pastebin get -f L6NhAYT7 term.lua |
2 | - | Программа для включения эффектов нанитов. |
2 | + | -- GPU Tier 2, Interner card, Wifi card, Tablet Tier 2 |
3 | - | |
3 | + | |
4 | - | требования: планшет или компьютер с wi-fi картой |
4 | + | local computer = require("computer") |
5 | - | примечание: могут одновременно активны только 2 эффекта |
5 | + | |
6 | - | |
6 | + | local colors = require("colors") |
7 | - | 4 назначить вход |
7 | + | local unicode = require("unicode") |
8 | - | номер входа 1-18 |
8 | + | |
9 | - | состояние вкл(1) выкл(2) |
9 | + | local sides = require("sides") |
10 | - | ]]-- |
10 | + | local gpu = component.gpu |
11 | - | |
11 | + | |
12 | local shell = require("shell") | |
13 | a = 0 | |
14 | shell.execute("oppm install nn") | |
15 | - | |
15 | + | term.clear() |
16 | - | local lastResponse = "" |
16 | + | shell.execute("nn init 53453") -- тут менять порт на свой |
17 | ports = 53454 -- и тут и еще ниже в функции 28 | |
18 | - | modem.open(1) |
18 | + | function funcButton1() |
19 | - | modem.broadcast(1, "nanomachines", "setResponsePort", 1) |
19 | + | if buttons.button1.buttonPressed == true then |
20 | - | |
20 | + | modem.broadcast(ports,"nanomachines","setInput",1,true) |
21 | - | local function printResponse() |
21 | + | else |
22 | - | local w, h = component.gpu.getResolution() |
22 | + | modem.broadcast(ports,"nanomachines","setInput",1,false) |
23 | - | component.gpu.fill(1, h, w, h, " ") |
23 | + | |
24 | - | component.gpu.set(1, h, lastResponse) |
24 | + | |
25 | function funcButton2() | |
26 | - | |
26 | + | if buttons.button2.buttonPressed == true then |
27 | - | local function handleModemMessage(_, _, _, _, _, header, command, ...) |
27 | + | modem.broadcast(ports,"nanomachines","setInput",2,true) |
28 | - | if header ~= "nanomachines" then return end |
28 | + | else |
29 | - | lastResponse = "последний ответ: " .. command |
29 | + | modem.broadcast(ports,"nanomachines","setInput",2,false) |
30 | - | for _, v in ipairs({...}) do |
30 | + | |
31 | - | lastResponse = lastResponse .. ", " .. tostring(v) |
31 | + | |
32 | - | end |
32 | + | function funcButton3() |
33 | - | printResponse() |
33 | + | if buttons.button3.buttonPressed == true then |
34 | modem.broadcast(ports,"nanomachines","setInput",3,true) | |
35 | - | |
35 | + | else |
36 | - | event.listen("modem_message", handleModemMessage) |
36 | + | modem.broadcast(ports,"nanomachines","setInput",3,false) |
37 | - | |
37 | + | |
38 | - | local function send(command, ...) |
38 | + | |
39 | - | component.modem.broadcast(1, "nanomachines", command, ...) |
39 | + | function funcButton4() |
40 | if buttons.button4.buttonPressed == true then | |
41 | - | |
41 | + | modem.broadcast(ports,"nanomachines","setInput",4,true) |
42 | - | local function readNumber(name, validator) |
42 | + | else |
43 | - | local index |
43 | + | modem.broadcast(ports,"nanomachines","setInput",4,false) |
44 | - | while not index do |
44 | + | |
45 | - | io.write(name..": ") |
45 | + | |
46 | - | index = tonumber(io.read()) |
46 | + | function funcButton5() |
47 | - | if not index or validator and not validator(index) then |
47 | + | if buttons.button5.buttonPressed == true then |
48 | - | index = nil |
48 | + | modem.broadcast(ports,"nanomachines","setInput",5,true) |
49 | - | io.write("такого входа не существует\n") |
49 | + | else |
50 | - | end |
50 | + | modem.broadcast(ports,"nanomachines","setInput",5,false) |
51 | - | end |
51 | + | |
52 | - | return index |
52 | + | |
53 | function funcButton6() | |
54 | - | |
54 | + | if buttons.button6.buttonPressed == true then |
55 | - | local running = true |
55 | + | modem.broadcast(ports,"nanomachines","setInput",6,true) |
56 | - | local commands = { |
56 | + | else |
57 | - | { "питание нанитов", |
57 | + | modem.broadcast(ports,"nanomachines","setInput",6,false) |
58 | - | function() |
58 | + | |
59 | - | send("getPowerState") |
59 | + | |
60 | - | end |
60 | + | function funcButton7() |
61 | - | }, |
61 | + | if buttons.button7.buttonPressed == true then |
62 | - | { "активные эфекты", |
62 | + | modem.broadcast(ports,"nanomachines","setInput",7,true) |
63 | - | function() |
63 | + | else |
64 | - | send("getActiveEffects") |
64 | + | modem.broadcast(ports,"nanomachines","setInput",7,false) |
65 | - | end |
65 | + | |
66 | - | }, |
66 | + | |
67 | - | { "состояние входа", |
67 | + | function funcButton8() |
68 | - | function() |
68 | + | if buttons.button8.buttonPressed == true then |
69 | - | local index = readNumber("номер входа") |
69 | + | modem.broadcast(ports,"nanomachines","setInput",8,true) |
70 | - | send("getInput", index) |
70 | + | else |
71 | - | end |
71 | + | modem.broadcast(ports,"nanomachines","setInput",8,false) |
72 | - | }, |
72 | + | |
73 | - | { "установить состояние входа", |
73 | + | |
74 | - | function() |
74 | + | function funcButton9() |
75 | - | local index = readNumber("номер входа") |
75 | + | if buttons.button9.buttonPressed == true then |
76 | - | io.write("1. влючить \n") |
76 | + | modem.broadcast(ports,"nanomachines","setInput",9,true) |
77 | - | io.write("2. выключить\n") |
77 | + | else |
78 | - | local value = readNumber("состояние", function(x) return x == 1 or x == 2 end) |
78 | + | modem.broadcast(ports,"nanomachines","setInput",9,false) |
79 | - | send("setInput", index, value == 1) |
79 | + | |
80 | - | end |
80 | + | |
81 | - | }, |
81 | + | function funcButton10() |
82 | - | { "количество входов", |
82 | + | if buttons.button10.buttonPressed == true then |
83 | - | function() |
83 | + | modem.broadcast(ports,"nanomachines","setInput",10,true) |
84 | - | send("getTotalInputCount") |
84 | + | else |
85 | - | end |
85 | + | modem.broadcast(ports,"nanomachines","setInput",10,false) |
86 | - | }, |
86 | + | |
87 | - | { "количество безопасных входов", |
87 | + | |
88 | - | function() |
88 | + | function funcButton11() |
89 | - | send("getSafeActiveInputs") |
89 | + | if buttons.button11.buttonPressed == true then |
90 | - | end |
90 | + | modem.broadcast(ports,"nanomachines","setInput",11,true) |
91 | - | }, |
91 | + | else |
92 | - | { "сколько всего активных входов", |
92 | + | modem.broadcast(ports,"nanomachines","setInput",11,false) |
93 | - | function() |
93 | + | |
94 | - | send("getMaxActiveInputs") |
94 | + | |
95 | - | end |
95 | + | function funcButton12() |
96 | - | }, |
96 | + | if buttons.button12.buttonPressed == true then |
97 | - | { "зодоровье игрока", |
97 | + | modem.broadcast(ports,"nanomachines","setInput",12,true) |
98 | - | function() |
98 | + | else |
99 | - | send("getHealth") |
99 | + | modem.broadcast(ports,"nanomachines","setInput",12,false) |
100 | - | end |
100 | + | |
101 | - | }, |
101 | + | |
102 | - | { "голод игрока", |
102 | + | function funcButton13() |
103 | - | function() |
103 | + | if buttons.button13.buttonPressed == true then |
104 | - | send("getHunger") |
104 | + | modem.broadcast(ports,"nanomachines","setInput",13,true) |
105 | - | end |
105 | + | else |
106 | - | }, |
106 | + | modem.broadcast(ports,"nanomachines","setInput",13,false) |
107 | - | { "возраст игрока", |
107 | + | |
108 | - | function() |
108 | + | |
109 | - | send("getAge") |
109 | + | function funcButton14() |
110 | - | end |
110 | + | if buttons.button14.buttonPressed == true then |
111 | - | }, |
111 | + | modem.broadcast(ports,"nanomachines","setInput",14,true) |
112 | - | { "имя игрока", |
112 | + | else |
113 | - | function() |
113 | + | modem.broadcast(ports,"nanomachines","setInput",14,false) |
114 | - | send("getName") |
114 | + | |
115 | - | end |
115 | + | |
116 | - | }, |
116 | + | function funcButton15() |
117 | - | { "опыт игрока", |
117 | + | if buttons.button15.buttonPressed == true then |
118 | - | function() |
118 | + | modem.broadcast(ports,"nanomachines","setInput",15,true) |
119 | - | send("getExperience") |
119 | + | else |
120 | - | end |
120 | + | modem.broadcast(ports,"nanomachines","setInput",15,false) |
121 | - | }, |
121 | + | |
122 | - | { "выход", |
122 | + | |
123 | - | function() |
123 | + | function funcButton16() |
124 | - | running = false |
124 | + | if buttons.button16.buttonPressed == true then |
125 | - | end |
125 | + | modem.broadcast(ports,"nanomachines","setInput",16,true) |
126 | - | } |
126 | + | else |
127 | - | } |
127 | + | modem.broadcast(ports,"nanomachines","setInput",16,false) |
128 | - | |
128 | + | |
129 | - | function main() |
129 | + | |
130 | - | while running do |
130 | + | function funcButton17() |
131 | - | term.clear() |
131 | + | if buttons.button17.buttonPressed == true then |
132 | - | for i = 1, #commands do |
132 | + | modem.broadcast(ports,"nanomachines","setInput",17,true) |
133 | - | local command = commands[i] |
133 | + | else |
134 | - | io.write(i," ",command[1],"\n") |
134 | + | modem.broadcast(ports,"nanomachines","setInput",17,false) |
135 | - | end |
135 | + | |
136 | - | printResponse() |
136 | + | |
137 | - | |
137 | + | function funcButton18() |
138 | - | local command = readNumber("введите команду", function(x) return x > 0 and x <= #commands end) |
138 | + | if buttons.button18.buttonPressed == true then |
139 | - | commands[command][2]() |
139 | + | modem.broadcast(ports,"nanomachines","setInput",18,true) |
140 | - | end |
140 | + | else |
141 | modem.broadcast(ports,"nanomachines","setInput",18,false) | |
142 | - | |
142 | + | |
143 | - | local result, reason = pcall(main) |
143 | + | |
144 | - | if not result then |
144 | + | function funcButton19() |
145 | - | io.stderr:write(reason, "\n") |
145 | + | shell.execute("nn test") |
146 | term.clear() | |
147 | - | |
147 | + | drawButtons() |
148 | - | event.ignore("modem_message", handleModemMessage) |
148 | + | |
149 | - | |
149 | + | function funcButton20() |
150 | - | term.clear() |
150 | + | shell.execute("nn get") |
151 | drawButtons() | |
152 | end | |
153 | function funcButton21() | |
154 | shell.execute("nn combo") | |
155 | term.clear() | |
156 | drawButtons() | |
157 | end | |
158 | function funcButton22() | |
159 | shell.execute("nn getcombo") | |
160 | drawButtons() | |
161 | end | |
162 | function funcButton23() | |
163 | shell.execute("nn copy") | |
164 | drawButtons() | |
165 | end | |
166 | function funcButton24() | |
167 | shell.execute("nn efon") | |
168 | drawButtons() | |
169 | end | |
170 | function funcButton25() | |
171 | shell.execute("nn clear") | |
172 | term.clear() | |
173 | drawButtons() | |
174 | end | |
175 | function funcButton26() | |
176 | shell.execute("nn reset") | |
177 | drawButtons() | |
178 | end | |
179 | function funcButton27() | |
180 | a = 1 | |
181 | end | |
182 | function funcButton28() | |
183 | shell.execute("nn init 53454") -- ТУт порт меняй | |
184 | term.clear() | |
185 | drawButtons() | |
186 | print("PORT SET:OK") | |
187 | end | |
188 | function funcButton29() | |
189 | for i = 1, 18 do | |
190 | modem.broadcast(ports,"nanomachines","setInput",i,false) | |
191 | os.sleep(1) | |
192 | end | |
193 | print("OFF:OK") | |
194 | end | |
195 | buttons = {button1 = {x=48, y=2, text=".1", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton1, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00}, | |
196 | button2 = {x=53, y=2, text=".2", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton2, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00}, | |
197 | button3 = {x=58, y=2, text=".3", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton3, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00}, | |
198 | button4 = {x=63, y=2, text=".4", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton4, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00}, | |
199 | button5 = {x=68, y=2, text=".5", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton5, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00}, | |
200 | button6 = {x=73, y=2, text=".6", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton6, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00}, | |
201 | button7 = {x=48, y=5, text=".7", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton7, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00}, | |
202 | button8 = {x=53, y=5, text=".8", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton8, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00}, | |
203 | button9 = {x=58, y=5, text=".9", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton9, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00}, | |
204 | button10 = {x=63, y=5, text="10", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton10, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00}, | |
205 | button11 = {x=68, y=5, text="11", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton11, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00}, | |
206 | button12 = {x=73, y=5, text="12", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton12, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00}, | |
207 | button13 = {x=48, y=8, text="13", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton13, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00}, | |
208 | button14 = {x=53, y=8, text="14", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton14, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00}, | |
209 | button15 = {x=58, y=8, text="15", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton15, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00}, | |
210 | button16 = {x=63, y=8, text="16", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton16, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00}, | |
211 | button17 = {x=68, y=8, text="17", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton17, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00}, | |
212 | button18 = {x=73, y=8, text="18", active=true, switchedButton = true, autoSwitch=false, buttonPressed = false, func = funcButton18, height=2, cFore = 0xFFFFFF, cBack = 0xFF0000, cFore1 = 0x000000, cBack1 = 0x00FF00}, | |
213 | button19 = {x=48, y=11, text="TEST", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton19, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF}, | |
214 | button20 = {x=56, y=11, text="GET.T", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton20, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF}, | |
215 | button21 = {x=64, y=11, text="COMBO", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton21, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF}, | |
216 | button22 = {x=72, y=11, text="G.COM", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton22, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF}, | |
217 | button23 = {x=48, y=14, text="COPY", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton23, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF}, | |
218 | button24 = {x=56, y=14, text="EFFEC", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton24, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF}, | |
219 | button25 = {x=64, y=14, text="CLEAR", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton25, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF}, | |
220 | button26 = {x=72, y=14, text="RESET", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton26, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF}, | |
221 | button27 = {x=72, y=17, text="EXIT", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton27, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF}, | |
222 | button28 = {x=64, y=17, text="PORT", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton28, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF}, | |
223 | button29 = {x=56, y=17, text="OFF", active=true, switchedButton = false, autoSwitch=false, buttonPressed = false, func = funcButton29, height=2, cFore = 0xFFFFFF, cBack = 0x0000FF}} | |
224 | function initButtons() | |
225 | for k,v in pairs(buttons) do | |
226 | v.width = unicode.wlen(v.text) + 2 | |
227 | end | |
228 | end | |
229 | initButtons() | |
230 | function drawButtons() | |
231 | ||
232 | for k,v in pairs(buttons) do | |
233 | if v.active then | |
234 | if not v.buttonPressed then -- если кнопка не нажата | |
235 | gpu.setForeground(v.cFore) | |
236 | gpu.setBackground(v.cBack) | |
237 | else -- в ином случае | |
238 | gpu.setForeground(v.cFore1) | |
239 | gpu.setBackground(v.cBack1) | |
240 | end | |
241 | gpu.fill(v.x, v.y, v.width, v.height, " ") -- фон для кнопки | |
242 | if v.height == 1 then -- если высота кнопки равна 1 | |
243 | gpu.set(v.x+1, v.y, v.text) | |
244 | elseif v.height%2 == 0 then -- если высота кнопки равна четному числу | |
245 | gpu.set(v.x+1, v.y + (v.height/2 - 1), v.text) | |
246 | elseif v.height%2 == 1 then -- если высота кнопки равна нечетному числу | |
247 | gpu.set(v.x+1, v.y + (math.ceil(v.height/2) - 1), v.text) | |
248 | end | |
249 | if v.autoSwitch == true and v.buttonPressed == true then | |
250 | v.buttonPressed = false | |
251 | os.sleep(2) | |
252 | drawButtons() | |
253 | end | |
254 | end | |
255 | end | |
256 | gpu.setForeground(0xFFFFFF) | |
257 | gpu.setBackground(0x000000) | |
258 | end | |
259 | ||
260 | function searchButton() | |
261 | ||
262 | while true do | |
263 | if a == 1 then | |
264 | term.clear() | |
265 | break | |
266 | end | |
267 | local _,_,x,y = event.pull("touch") | |
268 | for k,v in pairs(buttons) do | |
269 | if x >= v.x and x < v.x + v.width+2 and y >= v.y and y < v.y + v.height and v.active then | |
270 | if v.switchedButton == true then | |
271 | if not v.autoSwitch then | |
272 | if v.buttonPressed == false then | |
273 | v.buttonPressed = true | |
274 | else | |
275 | v.buttonPressed = false | |
276 | end | |
277 | else | |
278 | v.buttonPressed = true | |
279 | end | |
280 | term.clear() | |
281 | drawButtons() | |
282 | end | |
283 | v.func() | |
284 | end | |
285 | end | |
286 | end | |
287 | ||
288 | end | |
289 | ||
290 | drawButtons() | |
291 | searchButton() |