Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Импортируем библиотеки и объявлем переменные
- component = require("component")
- filesystem = require("filesystem")
- term = require("term")
- event = require("event")
- gpuadr = component.gpu.address
- gpu = component.proxy(gpuadr)
- stdresx, stdresy = gpu.getResolution()
- showcaseswitch = true
- --Создаем функции, связанные с ID
- function createReactorRegistry ()
- filesystem.makeDirectory("/etc/reactor/")
- print("Введите ID реактора")
- reactorid = io.read()
- local idcfg = io.open("/etc/reactor/reactorid", "w")
- io.output(idcfg)
- io.write(reactorid)
- io.close(idcfg)
- getReactorID()
- end
- function getReactorID ()
- if filesystem.exists("/etc/reactor/reactorid") then
- --Запись о реакторе есть, записываем ID в переменную
- local idcfg = io.open("/etc/reactor/reactorid")
- io.input(idcfg)
- reactorid = io.read()
- print("Использую реактор с ID:" .. reactorid)
- reactor = component.proxy(reactorid)
- else
- --Записи о реакторе нет, записываем ID в файл
- createReactorRegistry()
- end
- end
- --Создаем главную функцию
- function showcase ()
- getReactorID()
- gpu.setResolution(30, 4) --Ставим маленькое расширение для большого текста
- os.sleep(2)
- event.listen("key_up", settingsentrence) --Нажатие любой клавиши
- while true do
- if showcaseswitch == false then break end --Подготовка к переходу в настройки, выключение главного режима
- local running = reactor.getActive() --Получаем состояние
- local preftemp = reactor.getFuelTemperature() --Получаем температуру топлива
- local prectemp = reactor.getCasingTemperature() --Получаем температуру корпуса
- local ctemp = math.floor(prectemp) --Округляем температуру корпуса
- local ftemp = math.floor(preftemp) --Округляем температуру топлива
- if running == true then
- print("Реактор включен")
- end
- if running == false then
- print("Реактор выключен")
- end
- print("Температура топлива:" .. ftemp)
- term.write("Температура корпуса:" .. ctemp)
- os.sleep(1)
- term.clear()
- end end
- --Вход в настройки
- function settingsentrence ()
- event.ignore("key_up", settingsentrence)
- showcaseswitch = false
- ::settingsentrence::
- gpu.setResolution(stdresx, stdresy)
- term.clear()
- if filesystem.exists("/etc/reactor/settingspass") then
- print("Введите пароль")
- enteredpass = io.read()
- local passfile = io.open("/etc/reactor/settingspass")
- io.input(passfile)
- realpass = io.read()
- if realpass == enteredpass then
- io.close(passfile)
- settings()
- else
- goto settingsentrence
- end
- else
- print("Придумайте пароль")
- pass = io.read()
- local passfile = io.open("/etc/reactor/settingspass", "w")
- io.output(passfile)
- io.write(pass)
- io.close(passfile)
- end
- end
- --Текст по центру
- function centerText (a)
- x, y = term.getCursor()
- x = math.floor(stdresx / 2) - string.len(a)
- term.setCursor(x, y)
- term.write(a)
- end
- --Настройки
- function settings ()
- enteredpass = nil
- realpass = nil
- print("Настройки")
- print("1.Поменять пароль")
- print("2.Поменять ID реактора")
- print("3.Включить или выключить реактор")
- print("4.Вывести топливо")
- print("5.Вывести отходы")
- print("6.Вернуться в главный экран")
- print("7.Выход из программы")
- term.write("Команда:")
- uinput = io.read()
- end
- --Загрузили библиотеки и функции начинаем создавать ивент для входа в настройки
- showcase()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement