Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local c = require("component")
- local e = require("event")
- local color = require("colors")
- local term = require("term")
- local string = require("string")
- local m = c.modem
- local gpu = c.gpu
- local CFon,CText, CFig, CRed, CGreen, CBut = 0xAAAAAA, 0x5F5F5F, 0x313131, 0xCC4C4C, 0x279C38, 0xAAAAAA
- local NanAd,NanPort = '0bb35ff9-f2ca-4c58-863a-db6d5af8a229', 37536
- local Act = {}
- m.open(37536)
- --m.broadcast(37536,"nanomachines", "setResponsePort",37536)
- --m.send('0bb35ff9-f2ca-4c58-863a-db6d5af8a229',37536,"nanomachines","getHealth")
- --m.broadcast(37536,"nanomachines", "getHealth")
- local i = 0
- while i < 18 do --что файл что фор, всеравно 18 секунд((
- i = i+1
- local s = 0
- m.send(NanAd,NanPort,"nanomachines","getInput",i)
- while true do
- local e,_,_,_,_,_,_,_,s = e.pull("modem_message") --как прощелкать каждый вывод, возможно посмотри в другие проги
- if e == "modem_message" then
- if s == true then
- Act[i] = 1
- else
- Act[i] = 0
- end
- os.sleep(0.01)
- break
- end
- end
- end
- function WaitMsg() -- основное ожидание событий
- while true do
- term.setCursor(1,25)
- local ev,s2,CliX,but,s5,s6,mes,mes1,mes2 = e.pull()
- if ev == "modem_message" then
- if type(mes1) == "number" then
- mes1 = tonumber(mes1)
- --else
- end
- if type(mes2) == "number" then
- mes2 = tonumber(mes2)
- else
- mes2 = " "
- end
- --print("вроде как норм?")
- --mes1 = tonumber(mes1)
- --mes2 = tonumber(mes2)
- gpu.set(4,25,"Показатель: "..mes.." "..mes1.." "..mes2)
- os.sleep(2)
- gpu.fill(4,25,80,1," ")
- elseif ev == "touch" then
- if CliX>41 and CliX<58 then
- if but>3 and but<7 then
- m.send(NanAd,NanPort,"nanomachines","getHealth")
- elseif but>6 and but<10 then
- m.send(NanAd,NanPort,"nanomachines","getHunger")
- elseif but>9 and but<13 then
- m.send(NanAd,NanPort,"nanomachines","getPowerState")
- elseif but>12 and but<16 then
- m.send(NanAd,NanPort,"nanomachines","getAge")
- elseif but>15 and but<19 then
- m.send(NanAd,NanPort,"nanomachines", "getName")
- end
- elseif CliX>59 and CliX<76 then
- if but>3 and but<7 then
- m.send(NanAd,NanPort,"nanomachines","getActiveEffects")
- end
- elseif CliX>5 and CliX<12 then
- for i=1, 9 do
- if but==i*2+2 then
- if Act[i] == 0 then
- Act[i] = 1
- m.send(NanAd,NanPort,"nanomachines","setInput",i,true)
- gpu.setBackground(CGreen)
- gpu.set(13,i*2+2,tostring(i).." ")
- else
- Act[i] = 0
- m.send(NanAd,NanPort,"nanomachines","setInput",i,false)
- gpu.setBackground(CRed)
- gpu.set(13,i*2+2,tostring(i).." ")
- end
- end
- end
- elseif CliX>25 and CliX<32 then
- for i=1, 9 do
- if but==i*2+2 then
- if Act[i+9] == 0 then
- Act[i+9] = 1
- m.send(NanAd,NanPort,"nanomachines","setInput",i+9,true)
- gpu.setBackground(CGreen)
- gpu.set(23,i*2+2,tostring(i+9))
- else
- Act[i+9] = 0
- m.send(NanAd,NanPort,"nanomachines","setInput",i+9,false)
- gpu.setBackground(CRed)
- gpu.set(23,i*2+2,tostring(i+9))
- end
- end
- end
- end
- gpu.setBackground(CFon)
- elseif ev == "key_down" then
- if but == 16 then --Q
- gpu.set(4,25,"бай-бай")
- m.close(37536)
- gpu.setBackground(CFig)
- gpu.setForeground(CFon)
- os.sleep(2)
- term.clear()
- os.exit()
- end
- end
- --print(s2)--пишем всякую фигню(данные) чтоб зналь
- --print(CliX)
- --print(but)
- --print(s5)
- --print(s6)
- end
- end
- gpu.setBackground(CFon)
- gpu.setForeground(CText)
- term.clear()
- --term.setCursor(1,25)
- gpu.fill(1,24,80,1,"`")
- gpu.setForeground(CFig)
- gpu.set(12, 3,"╔════════════╗")
- for i = 1,17 do
- gpu.set(12,3+i,"║ ║")
- end
- gpu.set(12,21,"╚════════════╝")
- local xC = 4
- for i=1,9 do
- gpu.setBackground(CFon)
- gpu.fill(6,xC,6,1,"═")--6 29
- gpu.fill(26,xC,6,1,"═")
- if Act[i] == 0 then
- gpu.setBackground(CRed)
- gpu.set(13,xC,tostring(i).." ")
- else
- gpu.setBackground(CGreen)
- gpu.set(13,xC,tostring(i).." ")
- end
- if Act[i+9] == 0 then
- gpu.setBackground(CRed)
- gpu.set(23,xC,tostring(i+9))
- else
- gpu.setBackground(CGreen)
- gpu.set(23,xC,tostring(i+9))
- end
- xC = xC+2
- end
- gpu.setForeground(CText)
- gpu.setBackground(CBut)
- --gpu.fill(41,4,15,3," ")
- local xC = 4
- local sa = {"health","hunger","energy"," age"," name","effects","2","3","4","5"}
- for i = 1, 5 do
- gpu.set(42, xC, "╔══════════════╗")
- gpu.set(42,xC+1,"║ ║")--sa[i])
- gpu.set(42,xC+2,"╚══════════════╝")
- gpu.set(45,xC+1," "..sa[i])
- gpu.set(60, xC, "╔══════════════╗")
- gpu.set(60,xC+1,"║ ║")
- gpu.set(60,xC+2,"╚══════════════╝")
- gpu.set(63,xC+1," "..sa[i+5])
- xC = xC+3
- end
- function graff()
- end
- WaitMsg()
- --graff()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement