Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Подключаем нужные модули--
- local com = require("component")
- local gpu = com.gpu
- local term = require("term")
- local kb = require("keyboard")
- local color = require("colors")
- local br = com.br_reactor
- local comp = require("computer")
- local fs = require("filesystem")
- --Сохранение старых настроек--
- local OldB = gpu.getBackground()
- local OldF = gpu.getForeground()
- local OldW,OldH = gpu.getResolution()
- --Объявление функций--
- --"Текстовая коробка"--
- function textBox(x,y,text,colorF,colorB)
- if colorB ~= nil then
- gpu.setBackground(colorB,true)
- end
- if colorF ~= nil then
- gpu.setForeground(colorF,true)
- end
- gpu.set(x,y,tostring(text))
- end
- --Индикация температуры обшивки--
- function checkCT(CT,Y)
- if CT < 1000 then
- gpu.setBackground(color.gray,true)
- gpu.fill(26,Y,4,1," ")
- textBox(26,Y,CT,color.green)
- elseif CT > 1000 and CT < 1500 then
- gpu.setBackground(color.gray,true)
- gpu.fill(26,Y,4,1," ")
- textBox(26,Y,CT,color.yellow)
- elseif CT > 1500 then
- gpu.setBackground(color.gray,true)
- gpu.fill(26,Y,4,1," ")
- textBox(26,Y,CT,color.red)
- end
- end
- --Индикация температуры стержней--
- function checkFT(FT,Y)
- if FT < 1500 then
- gpu.setBackground(color.gray,true)
- gpu.fill(27,Y,4,1," ")
- textBox(27,Y,FT,color.green)
- elseif FT < 2000 then
- gpu.setBackground(color.gray,true)
- gpu.fill(27,Y,4,1," ")
- textBox(27,Y,FT,color.yellow)
- elseif FT > 2000 then
- gpu.setBackground(color.gray,true)
- gpu.fill(27,Y,4,1," ")
- textBox(27,Y,FT,color.red)
- end
- end
- --Отрисовка линии отображения--
- function drawLoadLine(x,y,weight,heidht,Value,colorB)
- gpu.setBackground(color.silver,true)
- gpu.fill(x,y,weight,heidht," ")
- gpu.setBackground(colorB,true)
- gpu.fill(x,y,weight/10*Value,heidht," ")
- end
- --Индикация статуса реактора--
- function checkOnOff()
- if br.getActive() then
- gpu.setBackground(color.green,true)
- gpu.setForeground(color.blue,true)
- gpu.set(5,24," ON ")
- gpu.setBackground(color.gray,true)
- gpu.setForeground(color.blue,true)
- gpu.set(9,24," OFF ")
- else
- gpu.setBackground(color.red,true)
- gpu.setForeground(color.blue,true)
- gpu.set(9,24," OFF ")
- gpu.setBackground(color.gray,true)
- gpu.setForeground(color.blue,true)
- gpu.set(5,24," ON ")
- end
- end
- --Ограничение линни отображения--
- function borderLoadLine(maxT,FT,CT)
- if FT > maxT then
- gpu.setBackground(color.gray,true)
- gpu.fill(75,18,5,1," ")
- end
- if CT > maxT then
- gpu.setBackground(color.gray,true)
- gpu.fill(75,18,5,1," ")
- end
- end
- function checkEnergy(x,y,ES)
- SES = string.len(ES)
- gpu.setBackground(color.gray,true)
- gpu.setForeground(color.blue,true)
- gpu.fill(x/2-(SES+2)/2,y,10,1," ")
- gpu.set(x/2-(SES+2)/2,y,tostring(ES).."RF")
- end
- function clearLine(Y,colorB)
- if colorB ~= nil then
- gpu.setBackground(colorB,true)
- end
- term.setCursor(1,Y)
- term.clearLine()
- end
- --Установка новых настроек--
- gpu.setResolution(80,25)
- gpu.setBackground(color.gray,true)
- gpu.setForeground(color.blue,true)
- term.clear()
- --Программа выбора реактора--
- gpu.setBackground(color.blue,true)
- gpu.fill(1,2,80,1," ")
- textBox(32.5,2,"Reactor Control",color.gray)
- textBox(29.5,4,"Выберите тип реактора",color.blue,color.gray)
- textBox(29,11,"Энергетический реактор",color.gray,color.blue)
- textBox(32.5,13,"Паровой реактор",color.gray,color.blue)
- textBox(70,24,"Выйти")
- while true do
- local type,_,sX,sY,_ = comp.pullSignal(0.1)
- if type == "touch" then
- if sX >= 29 and sX <= 51 then
- if sY >= 11 and sY <= 12 then
- clearLine(4)
- clearLine(11,color.gray)
- clearLine(13)
- goto EnergyReactor
- end
- end
- if sX >= 32 and sX <= 48 then
- if sY >= 13 and sY <= 14 then
- goto SteamReactor
- end
- end
- end
- end
- --Программа энергетического реактора--
- ::EnergyReactor::
- textBox(32,4,"Общая информация",color.blue,color.gray)
- clearLine(6,color.blue)
- textBox(5,15,"Температура стержней: ",nil,color.gray)
- textBox(5,18,"Температура обшивки: ")
- textBox(5,24," ON ")
- textBox(9,24," OFF ")
- while true do
- local FT = math.floor(br.getFuelTemperature())
- local CT = math.floor(br.getCasingTemperature())
- local ES = math.floor(br.getEnergyStored())
- local type,_,sX,sY,_ = comp.pullSignal(0.1)
- checkOnOff()
- checkFT(FT,15)
- drawLoadLine(5,16,70,1,FT/200,color.blue)
- checkCT(CT,18)
- drawLoadLine(5,19,70,1,CT/200,color.blue)
- checkEnergy(40,24,ES)
- drawLoadLine(5,22,70,1,ES/1000000,color.red)
- borderLoadLine(2000,FT,CT)
- --Реализация кнопок--
- if type == "touch" then
- --Кнопка выйти--
- if sX >= 70 and sX <= 75 then
- if sY >= 24 and sY <= 25 then
- goto Exit
- end
- end
- --Кнопка вкл.--
- if sX >= 5 and sX <= 9 then
- if sY >= 24 and sY <= 25 then
- br.setActive(true)
- end
- end
- --Кнопка выкл.--
- if sX >= 9 and sX <= 14 then
- if sY >= 24 and sY <= 25 then
- br.setActive(false)
- end
- end
- end
- end
- --Программа парового реактора--
- ::SteamReactor::
- textBox(32,4,"Общая информация")
- textBox(5,6,"Температура стержней: ",color.blue,color.gray)
- textBox(5,8,"Температура обшивки: ")
- textBox(5,10,"Количество пара: ")
- textBox(5,24," ON ")
- textBox(9,24," OFF ")
- while true do
- local FT = math.floor(br.getFuelTemperature())
- local CT = math.floor(br.getCasingTemperature())
- local HF = br.getHotFluidAmount()
- local type,_,sX,sY,_ = comp.pullSignal(0.1)
- checkOnOff()
- checkCT(CT,8)
- checkFT(FT,8)
- drawLoadLine(5,22,70,1,HF/400,color.blue)
- drawLoadLine(5,20,70,1,CT/200,color.blue)
- borderLoadLine(4000,FT,CT)
- --Реализация кнопок--
- if type == "touch" then
- --Кнопка выйти--
- if sX >= 70 and sX <= 75 then
- if sY >= 24 and sY <= 25 then
- goto Exit
- end
- end
- --Кнопка вкл.--
- if sX >= 5 and sX <= 9 then
- if sY >= 24 and sY <= 25 then
- br.setActive(true)
- end
- end
- --Кнопка выкл.--
- if sX >= 9 and sX <= 14 then
- if sY >= 24 and sY <= 25 then
- br.setActive(false)
- end
- end
- end
- end
- --Возвращение предыдущих настроек--
- ::Exit::
- gpu.setBackground(OldB)
- gpu.setForeground(OldF)
- gpu.setResolution(OldW,OldH)
- term.clear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement