Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local term = require("term")
- local note = require("note")
- local info = {password = 1234, adminPass = 228228, redstone = false, RedCorr = 3, RedIncor = 2, network = false, port = 512, sound = false}
- --Редстоун-сигналы
- function redTick(red, side)
- if red then
- if component.isAvailable("redstone") then
- component.redstone.setOutput(tonumber(side), 255)
- os.sleep(0.1)
- component.redstone.setOutput(tonumber(side), 0)
- else
- io.write("\nПлата на красном камне отсутствует. Данный тип сигнала невозможен!")
- end
- end
- end
- --Беспроводные сигналы
- function netSignal(network, port, typeS)
- if network then
- if component.isAvailable("modem") then
- if component.modem.isWireless() then
- if typeS == 1 then
- component.modem.broadcast(tonumber(port), "LockSignal", "True_Pass")
- elseif typeS == 2 then
- component.modem.broadcast(tonumber(port), "LockSignal", "Bad_Pass")
- else
- component.modem.broadcast(tonumber(port), "LockSignal", "Error")
- end
- else
- io.write("\nСетевая карта неспособна подовать беспроводные сообщения. Данный тип сигнала невозможен!")
- end
- else
- io.write("\nСетевая карта отсутствует. Данный тип сигнала невозможен!")
- end
- end
- end
- --Создание конфига
- local cfg = io.open("etc/Lock.cfg", "r")
- if cfg == nil then
- local CFG = io.open("etc/Lock.cfg", "w")
- CFG:write("password=1234\nadminPass=228228\nsound=true\nredstone=true\nRedCorr=3\nRedIncor=2\nnetwork=false\nport=512\nCreated by Pofigist\nVk: http://vk.com/pofigist_vip")
- CFG:close()
- cfg = io.open("etc/Lock.cfg", "r")
- end
- --Загрузка из конфига
- local buff = cfg:read("*a")
- info.password = string.match(buff, "password=".."(%d+)")
- info.adminPass = string.match(buff, "adminPass=".."(%d+)")
- if string.match(buff, "redstone=".."(%a+)") == "true" then info.redstone = true end
- info.RedCorr = string.match(buff, "RedCorr=".."(%d+)")
- info.RedIncor = string.match(buff, "RedIncor=".."(%d+)")
- if string.match(buff, "network=".."(%a+)") == "true" then info.network = true end
- info.port = string.match(buff, "port=".."(%d+)")
- if string.match(buff, "sound=".."(%a+)") == "true" then info.sound = true end
- --Основной цикл
- while true do
- term.clear()
- io.write("Введите пароль: ")
- local err, text = pcall(io.read)
- if text == info.password then
- if info.sound then note.play(90, 0.15) end
- io.write("Успешно разблокировано!")
- redTick(info.redstone, info.RedCorr)
- netSignal(info.network, info.port, 1)
- break
- elseif text == info.adminPass then
- io.write("Приветствуем Администрацию.")
- break
- else
- io.write("Неверный пароль! Повторите попытку. \n")
- if info.sound then note.play(68, 1) end
- redTick(info.redstone, info.RedIncor)
- netSignal(info.network, info.port, 2)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement