View difference between Paste ID: qwBM1LVQ and EHicgxw3
SHOW: | | - or go back to the newest paste.
1-
local c = require("component")
1+
local c = require("component")
2-
local e = require("event")
2+
local e = require("event")
3-
local color = require("colors")
3+
local color = require("colors")
4-
local term = require("term")
4+
local term = require("term")
5-
local string = require("string")
5+
local string = require("string")
6-
6+
local filesystem = require("filesystem")
7-
local m = c.modem
7+
8-
local gpu = c.gpu
8+
local m = c.modem
9-
local CFon,CText, CFig, CRed, CGreen, CBut = 0xAAAAAA, 0x5F5F5F, 0x313131, 0xCC4C4C, 0x279C38, 0xAAAAAA
9+
local gpu = c.gpu
10-
local NanAd,NanPort = '0bb35ff9-f2ca-4c58-863a-db6d5af8a229', 37536
10+
local CFon,CText, CFig, CRed, CGreen, CBut = 0xAAAAAA, 0x5F5F5F, 0x313131, 0xCC4C4C, 0x279C38, 0x9E9EFF
11-
local Act = {}
11+
local NanAd,NanPort = ' ', 1
12-
m.open(37536)
12+
local Lpage,colEff,Ladr,LInp,LInp2 = 0,0,0,0,1
13-
--m.broadcast(37536,"nanomachines", "setResponsePort",37536)
13+
local Act = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
14-
--m.send('0bb35ff9-f2ca-4c58-863a-db6d5af8a229',37536,"nanomachines","getHealth")
14+
local Act2 = {0,0,0,0,0,0,0,0,0,0,0,0}
15-
--m.broadcast(37536,"nanomachines", "getHealth")
15+
local RezIn= {} --сейв всех рабочих выводов (0,2:{moveSpeed,p.Hearts})
16-
16+
local SaveBut = {"1","2","3","4","5","6","7","8","9","10","11","12"}
17-
local i = 0
17+
local SaveBut2 = {0,0,0,0,0,0,0,0,0,0,0,0}
18-
18+
local Macr = {}
19-
while i < 18 do --что файл что фор, всеравно 18 секунд((
19+
--m.open(37536)
20-
  i = i+1
20+
--m.broadcast(1,"nanomachines", "setResponsePort",37536)
21-
  local s = 0
21+
--m.send('0bb35ff9-f2ca-4c58-863a-db6d5af8a229',37536,"nanomachines","getHealth")
22-
  m.send(NanAd,NanPort,"nanomachines","getInput",i)
22+
--m.broadcast(37536,"nanomachines", "getHealth")
23-
  while true do
23+
24-
  local e,_,_,_,_,_,_,_,s = e.pull("modem_message") --как прощелкать каждый вывод, возможно посмотри  в другие проги
24+
function OpenAll()
25-
    if e == "modem_message" then
25+
  file = io.open('nano.conf','r')
26-
26+
  local Zaa = file:read("*l")
27-
      if s == true then
27+
  colEff = tonumber(file:read("*l"))
28-
        Act[i] = 1
28+
  local da = 1
29-
      else
29+
  for i = 1, colEff  do
30-
        Act[i] = 0
30+
    local ad = string.find(Zaa,';',da+1)
31-
      end
31+
    RezIn[i] = string.sub(Zaa,da+1,ad-1)
32-
      os.sleep(0.01)
32+
    da = ad
33-
      break
33+
  end
34-
    end
34+
  local Zab = file:read("*l")
35-
  end
35+
  local da = 1
36-
end
36+
  for i = 1,18 do
37-
37+
    local dadd = string.byte(Zab,i*2)
38-
function WaitMsg() -- основное ожидание событий
38+
    Act[i] = tonumber(string.char(dadd))
39-
  while true do
39+
  end
40-
    term.setCursor(1,25)
40+
  NanAd = file:read("*l")
41-
41+
  NanPort = tonumber(file:read("*l"))   
42-
    local ev,s2,CliX,but,s5,s6,mes,mes1,mes2 = e.pull()
42+
  local Zac = file:read("*l")
43-
    if ev == "modem_message" then
43+
  local Zad = file:read("*l")
44-
      if type(mes1) == "number" then
44+
  local da,dad = 1,1
45-
      mes1 = tonumber(mes1)
45+
  for i = 1,12 do
46-
      --else
46+
    local ad = string.find(Zac,';',da+1)
47-
47+
    SaveBut[i] = string.sub(Zac,da+1,ad-1)
48-
      end
48+
    da = ad
49-
      if type(mes2) == "number" then
49+
    local dadd = string.find(Zad,';',dad+1)
50-
        mes2 = tonumber(mes2)
50+
    SaveBut2[i] = tonumber(string.sub(Zad,dad+1,dadd-1))
51-
      else
51+
    dad = dadd
52-
        mes2 = " "
52+
  end
53-
      end
53+
  local Zav = file:read("*l")
54-
      --print("вроде как норм?")
54+
  local da,ad = 1,1
55-
      --mes1 = tonumber(mes1)
55+
  --local tal = 
56-
      --mes2 = tonumber(mes2)
56+
  for i = 1, 1 do
57-
      gpu.set(4,25,"Показатель: "..mes.." "..mes1.." "..mes2)
57+
    local ad = string.find(Zav,';',da+1)
58-
      os.sleep(2)
58+
    Macr[i] = string.sub(Zav,da+1,ad-1)
59-
      gpu.fill(4,25,80,1," ")
59+
    da = ad
60-
    elseif ev == "touch" then
60+
  end
61-
      if CliX>41 and CliX<58 then 
61+
  file:close()
62-
        if but>3 and but<7 then
62+
  m.open(NanPort)
63-
          m.send(NanAd,NanPort,"nanomachines","getHealth")
63+
end
64-
        elseif but>6 and but<10 then
64+
65-
          m.send(NanAd,NanPort,"nanomachines","getHunger")
65+
function SaveAll()
66-
        elseif but>9 and but<13 then
66+
  file = io.open('nano.conf','w')
67-
          m.send(NanAd,NanPort,"nanomachines","getPowerState")
67+
  local Zaa,Zab,Zac,Zad,Zav = ";",";",";",";",";"
68-
        elseif but>12 and but<16 then
68+
  for i=1, colEff do
69-
          m.send(NanAd,NanPort,"nanomachines","getAge")
69+
    Zaa = Zaa..RezIn[i]..";"
70-
        elseif but>15 and but<19 then
70+
  end
71-
          m.send(NanAd,NanPort,"nanomachines", "getName")
71+
  for i=1, 18 do
72-
        end
72+
    Zab = Zab..Act[i]..";"  
73-
      elseif CliX>59 and CliX<76 then
73+
  end
74-
        if but>3 and but<7 then
74+
  for i=1,12 do
75-
          m.send(NanAd,NanPort,"nanomachines","getActiveEffects")
75+
    Zac = Zac..SaveBut[i]..";"
76-
        end
76+
    Zad = Zad..SaveBut2[i]..";"
77-
      elseif CliX>5 and CliX<12 then
77+
  end
78-
        for i=1, 9 do
78+
  for i = 1,1 do
79-
          if but==i*2+2 then
79+
    Zav = Zav..Macr[i]..";"
80-
            if Act[i] == 0 then
80+
  end
81-
              Act[i] = 1
81+
  file:write(Zaa.."\n")
82-
              m.send(NanAd,NanPort,"nanomachines","setInput",i,true)
82+
  file:write(colEff.."\n")
83-
              gpu.setBackground(CGreen)
83+
  file:write(Zab.."\n")
84-
              gpu.set(13,i*2+2,tostring(i).." ")
84+
  file:write(NanAd.."\n")
85-
            else
85+
  file:write(NanPort.."\n")
86-
              Act[i] = 0
86+
  file:write(Zac.."\n")
87-
              m.send(NanAd,NanPort,"nanomachines","setInput",i,false)
87+
  file:write(Zad.."\n")
88-
              gpu.setBackground(CRed)
88+
  file:write(Zav.."\n")
89-
              gpu.set(13,i*2+2,tostring(i).." ")
89+
  file:close()
90-
            end
90+
end
91-
          end
91+
92-
        end
92+
if not filesystem.exists("home/nano.conf") then
93-
      elseif CliX>25 and CliX<32 then
93+
  SaveAll()
94-
        for i=1, 9 do
94+
else
95-
          if but==i*2+2 then
95+
  OpenAll()
96-
            if Act[i+9] == 0 then
96+
end
97-
              Act[i+9] = 1
97+
98-
              m.send(NanAd,NanPort,"nanomachines","setInput",i+9,true)
98+
function WaitMsg() -- основное ожидание событий
99-
              gpu.setBackground(CGreen)
99+
  while true do
100-
              gpu.set(23,i*2+2,tostring(i+9))
100+
    term.setCursor(1,25)
101-
            else
101+
102-
              Act[i+9] = 0
102+
    local ev,s2,CliX,but,s5,s6,mes,mes1,mes2 = e.pull()
103-
              m.send(NanAd,NanPort,"nanomachines","setInput",i+9,false)
103+
    if ev == "modem_message" then
104-
              gpu.setBackground(CRed)
104+
      if type(mes1) == "number" then
105-
              gpu.set(23,i*2+2,tostring(i+9))
105+
        mes1 = tonumber(mes1)
106-
            end
106+
      else
107-
          end
107+
        mes1 = string.gsub(mes1,"particles","p")
108-
        end
108+
      end
109-
      end
109+
      if type(mes2) == "number" then
110-
    gpu.setBackground(CFon)
110+
        mes2 = tonumber(mes2)
111-
    elseif ev == "key_down" then
111+
      else
112-
      if but == 16 then --Q
112+
        mes2 = " "
113-
        gpu.set(4,25,"бай-бай")
113+
      end
114-
        m.close(37536)
114+
      --mes1 = string.gsub(mes1,"particles","p")
115-
        gpu.setBackground(CFig)
115+
      --print(mes1)
116-
        gpu.setForeground(CFon)
116+
      gpu.set(4,25,"Показатель: "..mes.." "..mes1.." "..mes2)
117-
        os.sleep(2)
117+
      os.sleep(2)
118-
        term.clear()
118+
      gpu.fill(4,25,80,1," ")
119-
        os.exit()
119+
      if Ladr == 1 then
120-
      end
120+
        NanAd = CliX
121-
    end
121+
        Ladr = 0
122-
    
122+
        local sts = 0
123-
    --print(s2)--пишем всякую фигню(данные) чтоб зналь
123+
        --check 171 input?
124-
    --print(CliX)
124+
        if LInp == 0 and LInp2 == 1 then
125-
    --print(but)
125+
          colEff = 0
126-
    --print(s5)
126+
        end
127-
    --print(s6)
127+
        for i = LInp,17 do
128-
  end
128+
          --1 input
129-
end
129+
          if sts == 1 then
130-
130+
            sts = 0
131-
gpu.setBackground(CFon)
131+
            break
132-
gpu.setForeground(CText)
132+
          end
133-
term.clear()
133+
          m.send(NanAd,NanPort,"nanomachines","setInput",i,true)
134-
--term.setCursor(1,25)
134+
          os.sleep(1)
135-
gpu.fill(1,24,80,1,"`")
135+
          for t = LInp2,18 do
136-
gpu.setForeground(CFig)
136+
            local r = t-i
137-
gpu.set(12, 3,"╔════════════╗")
137+
            if r>0 then
138-
for i = 1,17 do
138+
              --2 input
139-
gpu.set(12,3+i,"║            ║")
139+
              m.send(NanAd,NanPort,"nanomachines","setInput",t,true)
140-
end
140+
              os.sleep(1)
141-
gpu.set(12,21,"╚════════════╝")
141+
              m.send(NanAd,NanPort,"nanomachines","getActiveEffects")
142-
local xC = 4
142+
              gpu.fill(4,25,80,1," ")
143-
143+
              gpu.set(4,25,"Проверка входов "..i.." "..t)
144-
for i=1,9 do
144+
              --while true do
145-
  gpu.setBackground(CFon)
145+
                local evs,_,_,bby,_,_,_,ss,_ = e.pull()
146-
  gpu.fill(6,xC,6,1,"═")--6 29
146+
              --end
147-
  gpu.fill(26,xC,6,1,"═")
147+
               --print(evs)
148-
  if Act[i] == 0 then
148+
               if evs == "key_down" then
149-
    gpu.setBackground(CRed)
149+
                 if bby == 31 then --S
150-
    gpu.set(13,xC,tostring(i).." ")
150+
                   gpu.fill(4,25,80,1," ")
151-
  else
151+
                   gpu.set(4,25,"Процесс остановлен на "..i.." "..t)
152-
    gpu.setBackground(CGreen)
152+
                   SaveAll()
153-
    gpu.set(13,xC,tostring(i).." ")
153+
                   os.sleep(2)
154-
  end
154+
                   gpu.fill(4,25,80,1," ")
155-
  if Act[i+9] == 0 then
155+
                   sts = 1
156-
    gpu.setBackground(CRed)
156+
                   break
157-
    gpu.set(23,xC,tostring(i+9))
157+
                 end
158-
  else
158+
               end
159-
    gpu.setBackground(CGreen)
159+
              local hm = string.find(ss,'}')
160-
    gpu.set(23,xC,tostring(i+9))
160+
              if hm ~= 2 then
161-
  end
161+
                local skl = ""
162-
  xC = xC+2
162+
                local nnc,nns = 1,1
163-
end
163+
                ss = string.gsub(ss,"particles","p")
164-
164+
                if colEff == 0 then
165-
gpu.setForeground(CText)
165+
                  local ncc = string.len(ss)
166-
gpu.setBackground(CBut)
166+
                  ss = string.sub(ss,2,ncc-1)
167-
167+
                  colEff = 1
168-
--gpu.fill(41,4,15,3," ")
168+
                  RezIn[1] = i..","..t..","..ss
169-
local xC = 4
169+
                  gpu.fill(4,25,80,1," ")
170-
local sa = {"health","hunger","energy"," age"," name","effects","2","3","4","5"}
170+
                  --gpu.set(4,25,"Найденые эффекты "..RezIn[1])
171-
for i = 1, 5 do
171+
                else
172-
172+
                  for k in string.gmatch (ss, ",") do
173-
gpu.set(42, xC, "╔══════════════╗")
173+
                    local nnd = ""
174-
gpu.set(42,xC+1,"║              ║")--sa[i])
174+
                    local nnc2 = string.find(ss,',',nnc+1)
175-
gpu.set(42,xC+2,"╚══════════════╝")
175+
                    nnd = string.sub(ss,nns+1,nnc2-1)
176-
gpu.set(45,xC+1,"  "..sa[i])
176+
                    --print(nnc2)
177-
gpu.set(60, xC, "╔══════════════╗")
177+
                    nnc = nnc2
178-
gpu.set(60,xC+1,"║              ║")
178+
                    nns = nnc2
179-
gpu.set(60,xC+2,"╚══════════════╝")
179+
                    for i=1,colEff do--проверка 1 значения
180-
gpu.set(63,xC+1,"  "..sa[i+5])
180+
                      if type(string.match(RezIn[i],nnd))=='nil' then
181-
xC = xC+3
181+
                        --print("Nd2"..RezIn[i].."<>"..nnd)--nnd не делит
182-
end
182+
                        --os.sleep(1)
183-
function graff()
183+
                        if colEff == i then
184-
184+
                          skl = skl..","..nnd
185-
185+
                        end
186-
end
186+
                      else
187
                        --print("нашел совпадение")
188-
188+
                        
189-
--graff()
189+
                        break--чего натворил?ужс
190
                        --skl = skl..","..nnd
191
                      end
192
                    end
193
                    --skl = skl..","..nnd
194
                  end
195
                  local nmc=string.len(ss)
196
                  local nmd = string.sub(ss,nnc+1,nmc-1)
197
                  --print(nmd.."@ "..nnc)--повтор от 3 вывода+1
198
                  for i=1,colEff do
199
                    local hs = string.match(RezIn[i],nmd)
200
                    --print("Nd1"..RezIn[i].."<>"..nmd)
201
                    --os.sleep(1)
202
                    if type(hs) == 'nil' then
203
                      --print("Naid1")--с типом проблема?
204
                      if colEff == i then
205
                      skl = skl..","..nmd
206
                      end  
207
                    else
208
                      break  
209
                      --skl = skl..","..nmd
210
                    end
211
                  end
212
                  --skl = skl..","..nmd
213
                  --print(skl)
214
                  if skl ~= "" then
215
                    colEff = colEff+1
216
                    RezIn[colEff] = i..","..t..skl
217
                    --print(RezIn[colEff])
218
                    gpu.fill(4,25,80,1," ")
219
                    --gpu.set(4,25,"Найденые эффекты "..RezIn[colEff])
220
                  end
221
                end
222
              end
223
              os.sleep(0.25)
224
              m.send(NanAd,NanPort,"nanomachines","setInput",t,false)
225
              os.sleep(1)
226
            end
227
          end
228
          m.send(NanAd,NanPort,"nanomachines","setInput",i,false)
229
          os.sleep(1)
230
        end
231
        gpu.set(4,25,"Проверка входов завершена")
232
        os.sleep(0.5)
233
        gpu.fill(4,25,80,1," ")
234
      end
235
    elseif ev == "touch" then
236
      if CliX>38 and CliX<51 and but>1 and but<4 then
237
        Lpage = 0
238
        page()
239
        bugz()
240
      elseif CliX>50 and CliX<63 and but>1 and but<4 then
241
        Lpage = 1
242
        page()
243
        bugz()
244
      elseif CliX>62 and CliX<75 and but>1 and but<4 then
245
        Lpage = 2
246
        page()
247
        bugz()
248
      end
249
      if Lpage == 0 then
250
        if CliX>41 and CliX<58 then
251
          if but>4 and but<8 then
252
            m.send(NanAd,NanPort,"nanomachines","getName")
253
          elseif but>7 and but<11 then
254
            m.send(NanAd,NanPort,"nanomachines","getAge")
255
          elseif but>10 and but<14 then
256
            m.send(NanAd,NanPort,"nanomachines","getActiveEffects")
257
          elseif but>13 and but<17 then
258
            m.send(NanAd,NanPort,"nanomachines","getTotalInputCount")
259
          elseif but>16 and but<20 then
260
            m.send(NanAd,NanPort,"nanomachines", "getSafeActiveInput")
261
          elseif but>19 and but<23 then
262
            m.send(NanAd,NanPort,"nanomachines","getMaxActiveInput")
263
          end
264
        elseif CliX>59 and CliX<76 then
265
          if but>4 and but<8 then
266
            for i=1, 18 do
267
              local s = 0
268
              m.send(NanAd,NanPort,"nanomachines","getInput",i)
269
              while true do
270
                local e,_,_,_,_,_,_,_,s = e.pull("modem_message")
271
                if e == "modem_message" then
272
                  if s == true then
273
                    Act[i] = 1
274
                  else
275
                    Act[i] = 0
276
                  end
277
                  gpu.set(4,25,"Проверка входа "..i.." из 18")
278
                  os.sleep(0.01)
279
                  break
280
                end
281
              end
282
            end
283
            gpu.fill(4,25,80,1," ")
284
            bugz()
285
          elseif but>7 and but<11 then
286
            --check\scan+korektirovka adressa
287
            gpu.set(4,25,"С какого проверяем?(def 0) ")
288
            term.setCursor(31,25)
289
            LInp = tonumber(term.read(_,false))
290
            term.clearLine()
291
            gpu.set(4,25,"А второй?(def 1) ")
292
            term.setCursor(21,25)
293
            LInp2 = tonumber(term.read(_,false))
294
            term.clearLine()
295
            Ladr = 1
296
            m.broadcast(1,"nanomachines","getName")
297
          elseif but>10 and but<14 then
298
            gpu.set(4,25,"select port (1 to 65536):")
299
            term.setCursor(29,25)
300
            local LPort = tonumber(term.read(_,false))
301
            term.clearLine()
302
            m.send(NanAd,NanPort,"nanomachines","setResponsePort",LPort)
303
            m.open(LPort)
304
            m.close(NanPort)
305
            NanPort = LPort
306
          elseif but>13 and but<17 then
307
            for i=1,18 do
308
              Act[i]=0
309
            end
310
            bugz()
311
          elseif but>16 and but<20 then
312
            m.send(NanAd,NanPort,"nanomachines","saveConfiguration")
313
          elseif but>19 and but<23 then
314
            Lpage = 4
315
             gpu.set(4,25,"Select button")
316
            bugz()
317
            page()
318
            --configuration 2 page
319
          end
320
        elseif CliX>5 and CliX<12 then
321
          for i=1, 9 do
322
            if but==i*2+2 then
323
              if Act[i] == 0 then
324
                Act[i] = 1
325
                m.send(NanAd,NanPort,"nanomachines","setInput",i,true)
326
                gpu.setBackground(CGreen)
327
                gpu.set(13,i*2+2,tostring(i).." ")
328
              else
329
                Act[i] = 0
330
                m.send(NanAd,NanPort,"nanomachines","setInput",i,false)
331
                gpu.setBackground(CRed)
332
                gpu.set(13,i*2+2,tostring(i).." ")
333
              end
334
            end
335
          end
336
        elseif CliX>25 and CliX<32 then
337
          for i=1, 9 do
338
            if but==i*2+2 then
339
              if Act[i+9] == 0 then
340
                Act[i+9] = 1
341
                m.send(NanAd,NanPort,"nanomachines","setInput",i+9,true)
342
                gpu.setBackground(CGreen)
343
                gpu.set(23,i*2+2,tostring(i+9))
344
              else
345
                Act[i+9] = 0
346
                m.send(NanAd,NanPort,"nanomachines","setInput",i+9,false)
347
                gpu.setBackground(CRed)
348
                gpu.set(23,i*2+2,tostring(i+9))
349
              end
350
            end
351
          end
352
        end
353
      elseif Lpage == 1 then
354
        if CliX>41 and CliX<58 then
355
          for i = 1,6 do
356
            if but>(1+3*i) and but<(5+3*i) then
357
              if SaveBut2[i] ~= 0 then
358
                local ta = RezIn[SaveBut2[i]]
359
                local tad = string.find(ta,",")
360
                local taf = tonumber(string.sub(ta,1,tad-1))
361
                local tas = string.find(ta,",",tad+1)
362
                local tag = tonumber(string.sub(ta,tad+1,tas-1))
363
                if taf ~= 0 then
364
                  if Act2[i] == 0 then
365
                    m.send(NanAd,NanPort,"nanomachines","setInput",taf,true)
366
                    Act[taf] = 1
367
                  else
368
                    m.send(NanAd,NanPort,"nanomachines","setInput",taf,false)
369
                    Act[taf] = 0
370
                  end
371
                  os.sleep(1)
372
                end
373
                if Act2[i] == 0 then
374
                  m.send(NanAd,NanPort,"nanomachines","setInput",tag,true)
375
                  Act[tag] = 1
376
                  Act2[i] = 1
377
                  gpu.set(4,25,"Включено")
378
                else
379
                  m.send(NanAd,NanPort,"nanomachines","setInput",tag,false)
380
                  Act[tag] = 0
381
                  Act2[i] = 0
382
                  gpu.set(4,25,"Выключено")
383
                end
384
                os.sleep(1)
385
                gpu.fill(4,25,80,1," ")
386
              end
387
            end
388
          end
389
        elseif CliX>59 and CliX<76 then
390
          for i = 1,6 do
391
            if but>(1+3*i) and but<(5+3*i) then
392
              if SaveBut2[i+6] ~= 0 then
393
                local ta = RezIn[SaveBut2[i+6]]
394
                local tad = string.find(ta,",")
395
                local taf = tonumber(string.sub(ta,1,tad-1))
396
                local tas = string.find(ta,",",tad+1)
397
                local tag = tonumber(string.sub(ta,tad+1,tas-1))
398
                if taf ~= 0 then
399
                  if Act2[i+6] == 0 then
400
                    m.send(NanAd,NanPort,"nanomachines","setInput",taf,true)
401
                    Act[taf] = 1
402
                  else
403
                    m.send(NanAd,NanPort,"nanomachines","setInput",taf,false)
404
                    Act[taf] = 0
405
                  end
406
                  os.sleep(1)
407
                end
408
                if Act2[i+6] == 0 then
409
                  m.send(NanAd,NanPort,"nanomachines","setInput",tag,true)
410
                  Act[tag] = 1
411
                  Act2[i+6] = 1
412
                  gpu.set(4,25,"Включено")
413
                else
414
                  m.send(NanAd,NanPort,"nanomachines","setInput",tag,false)
415
                  Act[tag] = 0
416
                  Act2[i+6] = 0
417
                  gpu.set(4,25,"Выключено")
418
                end
419
                os.sleep(1)
420
                gpu.fill(4,25,80,1," ")
421
              end
422
            end
423
          end
424
        end
425
      elseif Lpage == 4 then
426
        local LSel = 0
427
        ---for i = 1,6 do
428
          ---but
429
        ---end
430
        if CliX>41 and CliX<58 then
431
          if but>4 and but<8 then
432
            --переменная? выбор эффекта из RezIn + название кнопки
433
            --наверно можно циклом
434
            LSel = 1
435
          elseif but>7 and but<11 then
436
            --m.send(NanAd,NanPort,"nanomachines","getAge")
437
            LSel = 2
438
          elseif but>10 and but<14 then
439
            --m.send(NanAd,NanPort,"nanomachines","getActiveEffects")
440
            LSel = 3
441
          elseif but>13 and but<17 then
442
            --m.send(NanAd,NanPort,"nanomachines","getTotalInputCount")
443
            LSel = 4
444
          elseif but>16 and but<20 then
445
            --m.send(NanAd,NanPort,"nanomachines", "getSafeActiveInput")
446
            LSel = 5
447
          elseif but>19 and but<23 then
448
            --m.send(NanAd,NanPort,"nanomachines","getMaxActiveInput")
449
            LSel = 6
450
          end
451
        elseif CliX>59 and CliX<76 then
452
          if but>4 and but<8 then
453
            LSel = 7
454
          elseif but>7 and but<11 then
455
            LSel = 8
456
           -- m.send(NanAd,NanPort,"nanomachines","getAge")
457
          elseif but>10 and but<14 then
458
            LSel = 9
459
           -- m.send(NanAd,NanPort,"nanomachines","getActiveEffects")
460
          elseif but>13 and but<17 then
461
            LSel = 10
462
            --m.send(NanAd,NanPort,"nanomachines","getTotalInputCount")
463
          elseif but>16 and but<20 then
464
            LSel = 11
465
            --m.send(NanAd,NanPort,"nanomachines", "getSafeActiveInput")
466
          elseif but>19 and but<23 then
467
            LSel = 12
468
            --m.send(NanAd,NanPort,"nanomachines","getMaxActiveInput")
469
          end
470
        end
471
        gpu.set(4,25,"Select input")
472
        while true do
473
          local evs,_,Sp,bby,_,_,_,ss,_ = e.pull()
474
          if  evs == "touch" then
475
            if Sp>1 and Sp<35 then
476
              --RezIn[bby+1]
477
              SaveBut2[LSel] = bby-1
478
              --
479
            gpu.set(4,25,"Select name button ")
480
            term.setCursor(24,25)
481
            --SaveBut[LSel]
482
            local gas = term.read(_,false)--минус интер
483
            local ga = string.len(gas)
484
            SaveBut[LSel] = string.sub(gas,1,ga-1)
485
            term.clearLine()
486
            break
487
            end
488
          end
489
        end
490
      end
491
    gpu.setBackground(CFon)
492
    elseif ev == "key_down" then
493
      if but == 16 then --Q
494
        gpu.set(4,25,"бай-бай")
495
        m.close(NanPort)
496
        gpu.setBackground(CFig)
497
        gpu.setForeground(CFon)
498
        SaveAll()
499
        os.sleep(2)
500
        term.clear()
501
        os.exit()
502
      end
503
    end
504
    
505
    --print(s2)--пишем всякую фигню(данные) чтоб зналь
506
    --print(CliX)
507
    --print(but)
508
    --print(s5)
509
    --print(s6)
510
  end
511
end
512
513
function bugz()
514
  gpu.setForeground(CFig)
515
  gpu.fill(2,2,34,20," ")
516
  if Lpage == 4 or Lpage == 1 then
517
    for i = 1, colEff do
518
      if math.fmod(i,2) == 0 then
519
        gpu.setBackground(CBut)
520
      else
521
        gpu.setBackground(CFon)
522
      end
523
      gpu.fill(2,i+1,34,1," ")
524
      gpu.set(2,i+1,RezIn[i])
525
    end
526
  else
527
    
528
    gpu.set(12, 3,"╔════════════╗")
529
    for i = 1,17 do
530
      gpu.set(12,3+i,"║            ║")
531
    end
532
    gpu.set(12,21,"╚════════════╝")
533
 
534
    local xC = 4
535
    for i=1,9 do
536
      gpu.setBackground(CFon)
537
      gpu.fill(6,xC,6,1,"═")--6 29
538
      gpu.fill(26,xC,6,1,"═")
539
      if Act[i] == 0 then
540
        gpu.setBackground(CRed)
541
        gpu.set(13,xC,tostring(i).." ")
542
      else
543
        gpu.setBackground(CGreen)
544
        gpu.set(13,xC,tostring(i).." ")
545
      end
546
      if Act[i+9] == 0 then
547
        gpu.setBackground(CRed)
548
        gpu.set(23,xC,tostring(i+9))
549
      else
550
        gpu.setBackground(CGreen)
551
        gpu.set(23,xC,tostring(i+9))
552
      end
553
      xC = xC+2
554
    end
555
  end
556
  gpu.setForeground(CText)
557
  gpu.setBackground(CFon)
558
end
559
function graff()
560
  gpu.setBackground(CFon)
561
  gpu.setForeground(CText)
562
  term.clear()
563
--term.setCursor(1,25)
564
  gpu.fill(1,24,80,1,"`")
565
  bugz()
566
--gpu.fill(41,4,15,3," ")
567
  
568
  gpu.set(39,2,"╔══════════╗╔══════════╗╔══════════╗")
569
  gpu.set(39,3,"║  CONFIG  ║║  EFFECT  ║║  MACROS  ║")
570
  for i = 1,18 do
571
    gpu.set(37,4+i,"║                                      ║")
572
  end
573
  gpu.set(37,23,"╚══════════════════════════════════════╝")
574
  page()
575
end
576
577
function page()
578
  local LLstr = " "
579
  for i = 1,18 do
580
    gpu.set(38,i+4,"                                     ")
581
  end
582
  if Lpage == 0 then
583
    LLstr = "╔═╝          ╚╩══════════╩╩══════════╩═╗"
584
    local xC = 4
585
    local sa = {"   name","   age"," effects","totalInput","safeInput"," maxInput","  check","   scan","changePort","  clear","saveConfig","saveEffects"}
586
    for i = 1, 6 do
587
      gpu.set(40,xC+1,"╔══════════════╗  ╔══════════════╗")
588
      gpu.set(40,xC+2,"║              ║  ║              ║")
589
      gpu.set(40,xC+3,"╚══════════════╝  ╚══════════════╝")
590
      gpu.set(41,xC+2,"  "..sa[i])
591
      gpu.set(59,xC+2,"  "..sa[i+6])
592
      xC = xC+3
593
    end
594
  elseif Lpage == 1 or Lpage == 4 then
595
    LLstr = "╔═╩══════════╩╝          ╚╩══════════╩═╗"
596
    local xC = 4
597
    for i = 1,6 do
598
      gpu.set(40,xC+1,"╔══════════════╗  ╔══════════════╗")
599
      gpu.set(40,xC+2,"║              ║  ║              ║")
600
      gpu.set(40,xC+3,"╚══════════════╝  ╚══════════════╝")
601
      gpu.set(42,xC+2,"  "..SaveBut[i])
602
      gpu.set(61,xC+2,"  "..SaveBut[i+6])
603
      xC = xC+3
604
    end
605
  else
606
    LLstr = "╔═╩══════════╩╩══════════╩╝          ╚═╗"
607
  --page MACROS
608
    gpu.set(41,5,"Page 1")
609
    gpu.set(41,6,"Условие |P|H|U|A|N|E|      ╳ ")
610
    gpu.set(41,7,"[Health] < [500]")
611
    gpu.set(41,8,"Действие ")-- твори странички)
612
    gpu.set(41,9,"[Вкл]  вход [0]")
613
    gpu.set(38,10,"[-][Выкл] вход [4]")
614
    gpu.set(41,11,"[+]")
615
  end
616
  gpu.set(37, 4,LLstr)
617
end
618
619
graff()
620
621
WaitMsg()