Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local comp = require('component')
- local stargate = comp.stargate
- local term = require('term')
- local event=require('event')
- local gpu=require('component').gpu
- local disp = {gpu.getResolution()}
- local width = 80
- local height = 25
- local timeout = 1
- local key_neth = 'W9MX-YD7-MF'
- local key_end = 0
- local SG_chek = false
- local address = '0000'
- local color = {
- back=0x000000,
- foreg=0xffffff,
- exit=0xff0000,
- stg=0xbebebe,
- stg2=0xc0c0c0,
- stg3=0x808080,
- stg4=0x545454
- }
- local draw = {" ", "█", "*", "█", "░"}
- local frame = {2,99,80,0,2,1,99,43,2,1,99,34,2,0,2,1,99,43,2,1,99,34,2,0,2,1,99,43,2,1,99,34,2,0,
- 2,1,99,43,2,1,99,34,2,0,2,1,99,43,2,1,99,34,2,0,2,1,99,43,2,1,99,34,2,0,2,1,99,43,2,1,99,34,2,0,
- 2,1,99,43,2,1,99,34,2,0,2,1,99,43,2,1,99,34,2,0,2,1,99,43,2,1,99,34,2,0,2,1,99,43,2,1,99,34,2,0,
- 2,1,99,43,2,1,99,34,2,0,2,1,99,43,2,1,99,34,2,0,2,1,99,43,2,1,99,34,2,0,2,1,99,43,2,1,99,34,2,0,
- 2,1,99,43,2,1,99,34,2,0,2,1,99,43,2,1,99,34,2,0,2,1,99,43,2,1,99,34,2,0,2,1,99,43,2,1,99,34,2,0,
- 2,1,99,43,2,1,99,34,2,0,2,1,99,43,2,1,99,34,2,0,2,1,99,43,2,1,99,34,2,0,2,1,99,43,2,1,99,34,2,0,
- 2,99,80}
- local function drawfn(clr, t, wX, wY)
- if clr then -- очитить экран?
- term.clear()
- clr = false
- end
- wXst=wX
- term.setCursor(wX, wY)
- for i = 1, #t do
- if t[i]==0 then -- Если "0" - конец строки - перейти на новую строку
- wY=wY+1
- wX=wXst
- elseif t[i]==99 then -- если 99 - напечатать N-е количество таких символов
- ch=true
- elseif ch then
- ch=false
- tt=t[i]
- for a=1, tt-1 do --цикл печати повторяющихся символов
- term.setCursor(wX, wY)
- term.write(draw[Vst])
- wX=wX+1
- end
- else
- Vst=t[i]
- term.setCursor(wX, wY)
- term.write(draw[t[i]])
- wX=wX+1
- end
- end
- end
- local function sg_addr() -- подключение к вратам
- stargate.dial(address)
- gpu.set(20, 23, "соединение?"); os.sleep(0.5); gpu.set(20, 23, " ") -- отладка
- os.sleep(60) -- время когда врата открыты
- stargate.disconnect()
- end
- local function starg()
- -- проверить соединение
- -- вывести предупреждение
- sg_addr()
- end
- local function draw() -- вывести заставку
- clr = true
- wX = 1; wY = 1
- t = frame
- drawfn(clr, t, wX, wY) -- вывести фоновую заставку
- gpu.setBackground(color.stg3) -- цвет фон
- gpu.setForeground(color.back) -- цвет текст
- gpu.fill(14, 8, 20, 3, " ")
- gpu.set(19, 9, "N E T H E R")
- gpu.fill(14, 14, 20, 3, " ")
- gpu.set(22, 15, "E N D")
- --рисуем кнопку выхода
- gpu.setBackground(color.exit)
- gpu.set(2, 24, "exit")
- end
- local function touch(_,_, x, y)
- if x>13 and x<35 and y>7 and y<11 then
- local address = key_neth
- SG_chek = true
- gpu.setBackground(color.stg3) -- цвет фон
- gpu.setForeground(color.back) -- цвет текст
- gpu.set(20, 23, key_neth); os.sleep(0.5); gpu.set(20, 23, " ") -- отладка
- gpu.set(22, 21, "N E T H E R");os.sleep(0.5);gpu.set(22, 21, " ") -- отладка
- elseif x>13 and x<35 and y>13 and y<17 then
- gpu.setBackground(color.stg3) -- цвет фон
- gpu.setForeground(color.back) -- цвет текст
- gpu.set(22, 21, "E N D");os.sleep(0.5);gpu.set(22, 21, " ") -- отладка
- elseif x>1 and x<6 and y==24 then -- отладка
- quit = true -- "exit"
- end
- end
- local function even_ON() event.listen('touch', touch); end
- local function even_OFF() event.ignore('touch', touch); end
- -------- Программа ---------
- local function main()
- gpu.setBackground(color.stg) -- цвет фон
- gpu.setForeground(color.stg4) -- цвет текст
- draw()
- while true do
- os.sleep(timeout)
- if SG_chek then even_OFF(); starg(); SG_chek = false; even_ON(); end
- if quit then break end -- отладка
- end
- even_OFF()
- gpu.setBackground(color.back)
- gpu.setForeground(color.foreg)
- gpu.setResolution(disp[1], disp[2])
- end
- even_ON()
- gpu.setResolution(width, height) -- новое разрешение
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement