Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----APIS----
- local component = require("component")
- local event = require("event")
- local fs = require("filesystem")
- local shell = require("shell")
- local os = require("os")
- local sides = require("sides")
- local rs = component.redstone
- local gpu = component.gpu
- local screen_list = {}
- local conf = nil
- -------------
- ------Variables-----
- local Users = { "PandaJade" }
- local Locked = true
- local UsingBlock = false
- local BlockAddress = nil
- local OutputSide = 0
- function Main()
- if (conf.GetConfig("Security.cfg", 1) == true) then
- UsingBlock = true
- BlockAddress = component.proxy(component.get(conf.GetConfig("Security.cfg", 3), "redstone"))
- end
- for k,v in component.list("screen") do
- table.insert(screen_list, k)
- end
- INDEX = 1
- OutputSide = conf.GetSide(conf.GetConfig("Security.cfg", 2))
- for k,v in pairs(screen_list) do
- gpu.bind(v)
- gpu.setResolution(40, 20)
- gpu.fill(1, 1, 40, 20, " ")
- gpu.setForeground(0x00FFFF)
- gpu.set(2, 1, "Jades's Handprint Identificator v1.1")
- INDEX = INDEX + 1
- end
- Paint()
- Listen()
- end
- function lock()
- Locked = true
- Paint()
- end
- function Paint()
- local Color = 0xFF0000
- if (Locked == false) then
- gpu.setForeground(0x00FF00)
- else
- gpu.setForeground(0xFF0000)
- end
- gpu.set(17, 5, "_ _ _")
- gpu.set(16, 6, "| | | |_")
- gpu.set(16, 7, "| | | | |")
- gpu.set(15, 8, "_| | | | |")
- gpu.set(14, 9, "| | | | | |")
- gpu.set(14, 10, "| | |")
- gpu.set(14, 11, "\\ |")
- gpu.set(15, 12, "\\ |")
- gpu.set(16, 13, "\\ /")
- gpu.set(17, 14, "| |")
- gpu.fill(1, 16, 40, 1, " ")
- if (Locked == false) then
- gpu.set(14, 16, "Access Granted")
- else
- gpu.set(17, 16, "Locked")
- end
- if (Locked == false) then
- if (UsingBlock) then
- BlockAddress.setOutput(OutputSide, 255)
- else
- rs.setOutput(OutputSide, 255)
- end
- os.sleep(10)
- lock()
- else
- if (UsingBlock) then
- BlockAddress.setOutput(OutputSide, 0)
- else
- rs.setOutput(OutputSide, 0)
- end
- end
- end
- function Listen()
- while true do
- local id, address, side, _, __, Name2 = event.pullMultiple("touch", "redstone_changed")
- if (id == "touch") then
- Animate()
- gpu.setBackground(0x000000)
- local Granted = false
- for _, OK in ipairs(Users) do
- if (Name2 == OK) then
- Granted = true
- break
- end
- end
- if (Granted == true) then
- if (Locked == true) then
- Locked = false
- end
- end
- Paint()
- elseif (id == "redstone_changed") then
- ---OVERRIDE
- if not (OutputSide == side) then
- Locked = false
- Paint()
- end
- end
- end
- end
- function Animate()
- gpu.fill(1, 16, 40, 1, " ")
- gpu.set(16, 16, "Scanning...")
- local Y = 4
- while true do
- Y = Y + 1
- gpu.setBackground(0xFFFF00)
- if (Y ~= 16) then
- gpu.fill(1, Y, 40, 1, " ")
- end
- gpu.setBackground(0x000000)
- if (Y > 2) and (Y ~= 17) then
- gpu.fill(1, Y-1, 40, 1, " ")
- end
- if (Y == 6) then
- gpu.set(17, 5, "_ _ _")
- end
- if (Y == 7) then
- gpu.set(16, 6, "| | | |_")
- end
- if (Y == 8) then
- gpu.set(16, 7, "| | | | |")
- end
- if (Y == 9) then
- gpu.set(15, 8, "_| | | | |")
- end
- if (Y == 10) then
- gpu.set(14, 9, "| | | | | |")
- end
- if (Y == 11) then
- gpu.set(14, 10, "| | |")
- end
- if (Y == 12) then
- gpu.set(14, 11, "\\ |")
- end
- if (Y == 13) then
- gpu.set(15, 12, "\\ |")
- end
- if (Y == 14) then
- gpu.set(16, 13, "\\ /")
- end
- if (Y == 15) then
- gpu.set(17, 14, "| |")
- end
- os.sleep(0.1)
- if (Y == 16) then
- break
- end
- end
- end
- function CheckAPI()
- if not fs.exists("lib/API_Config.lua") then
- print("[API NOT FOUND: Config] Attempting To Download...")
- shell.execute("pastebin get TPBGxPrZ /lib/API_Config.lua")
- end
- conf = require("API_Config")
- ----LOADING CONFIG-----
- if not conf.ConfigExists("Security.cfg") then
- conf.EditConfig("Security.cfg", 1, "Using Redstone Block: ", "Boolean")
- if (conf.GetConfig("Security.cfg", 1) == true) then
- conf.EditConfig("Security.cfg", 2, "Redstone Output: ", "Direction")
- conf.EditConfig("Security.cfg", 3, "Redstone Block Address: ", "Direction")
- else
- conf.EditConfig("Security.cfg", 2, "Redstone Output: ", "Facing")
- end
- end
- if conf.GetConfig("Security.cfg", 1) == nil then print("CONFIGURATION REQUIRED!") conf.EditConfig("Security.cfg", 1, "Using Redstone Block: ", "Boolean") end
- if conf.GetConfig("Security.cfg", 2) == nil then
- print("CONFIGURATION REQUIRED!")
- if (conf.GetConfig("Security.cfg", 1) == true) then
- conf.EditConfig("Security.cfg", 2, "Redstone Output: ", "Direction")
- else
- conf.EditConfig("Security.cfg", 2, "Redstone Output: ", "Facing")
- end
- end
- if (conf.GetConfig("Security.cfg", 1) == true) then
- if conf.GetConfig("Security.cfg", 3) == nil then print("CONFIGURATION REQUIRED!") conf.EditConfig("Security.cfg", 3, "Redstone Block Address: ", "String") end
- end
- Main()
- end
- CheckAPI()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement