Advertisement
XDemonic

Handprint Scanner - OC

May 28th, 2020 (edited)
1,219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.97 KB | None | 0 0
  1. -----APIS----
  2. local component = require("component")
  3. local event = require("event")
  4. local fs = require("filesystem")
  5. local shell = require("shell")
  6. local os = require("os")
  7. local sides = require("sides")
  8. local rs = component.redstone
  9. local gpu = component.gpu
  10. local screen_list = {}
  11. local conf = nil
  12. -------------
  13. ------Variables-----
  14. local Users = { "PandaJade" }
  15. local Locked = true
  16. local UsingBlock = false
  17. local BlockAddress = nil
  18. local OutputSide = 0
  19.  
  20. function Main()
  21.     if (conf.GetConfig("Security.cfg", 1) == true) then
  22.         UsingBlock = true
  23.         BlockAddress = component.proxy(component.get(conf.GetConfig("Security.cfg", 3), "redstone"))
  24.     end
  25.     for k,v in component.list("screen") do
  26.         table.insert(screen_list, k)
  27.     end
  28.     INDEX = 1
  29.     OutputSide = conf.GetSide(conf.GetConfig("Security.cfg", 2))
  30.     for k,v in pairs(screen_list) do
  31.         gpu.bind(v)
  32.         gpu.setResolution(40, 20)
  33.         gpu.fill(1, 1, 40, 20, " ")
  34.         gpu.setForeground(0x00FFFF)
  35.         gpu.set(2, 1, "Jades's Handprint Identificator v1.1")
  36.         INDEX = INDEX + 1
  37.     end
  38.     Paint()
  39.     Listen()
  40. end
  41.  
  42. function lock()
  43. Locked = true
  44. Paint()
  45. end
  46.  
  47. function Paint()
  48. local Color = 0xFF0000
  49.     if (Locked == false) then
  50.         gpu.setForeground(0x00FF00)
  51.     else
  52.         gpu.setForeground(0xFF0000)
  53.     end
  54.     gpu.set(17, 5, "_ _ _")
  55.     gpu.set(16, 6, "| | | |_")
  56.     gpu.set(16, 7, "| | | | |")
  57.     gpu.set(15, 8, "_| | | | |")
  58.     gpu.set(14, 9, "| | | | | |")
  59.     gpu.set(14, 10, "| |       |")
  60.     gpu.set(14, 11, "\\         |")
  61.     gpu.set(15, 12, "\\        |")
  62.     gpu.set(16, 13, "\\      /")
  63.     gpu.set(17, 14, "|    |")
  64.     gpu.fill(1, 16, 40, 1, " ")
  65.     if (Locked == false) then
  66.         gpu.set(14, 16, "Access Granted")
  67.     else
  68.         gpu.set(17, 16, "Locked")
  69.     end
  70.     if (Locked == false) then
  71.         if (UsingBlock) then
  72.             BlockAddress.setOutput(OutputSide, 255)
  73.         else
  74.             rs.setOutput(OutputSide, 255)
  75.         end
  76.         os.sleep(10)
  77.         lock()
  78.     else
  79.         if (UsingBlock) then
  80.             BlockAddress.setOutput(OutputSide, 0)
  81.         else
  82.             rs.setOutput(OutputSide, 0)
  83.         end
  84.     end
  85. end
  86.  
  87. function Listen()
  88.     while true do
  89.     local id, address, side, _, __, Name2 = event.pullMultiple("touch", "redstone_changed")
  90.     if (id == "touch") then
  91.         Animate()
  92.         gpu.setBackground(0x000000)
  93.             local Granted = false
  94.             for _, OK in ipairs(Users) do
  95.                 if (Name2 == OK) then
  96.                     Granted = true
  97.                     break
  98.                 end
  99.             end
  100.             if (Granted == true) then
  101.                 if (Locked == true) then
  102.                     Locked = false
  103.                 end
  104.             end
  105.             Paint()
  106.     elseif (id == "redstone_changed") then
  107.     ---OVERRIDE
  108.         if not (OutputSide == side) then
  109.             Locked = false
  110.             Paint()
  111.         end
  112.     end
  113.     end
  114. end
  115.  
  116. function Animate()
  117.         gpu.fill(1, 16, 40, 1, " ")
  118.         gpu.set(16, 16, "Scanning...")
  119.         local Y = 4
  120.         while true do
  121.             Y = Y + 1
  122.                 gpu.setBackground(0xFFFF00)
  123.                 if (Y ~= 16) then
  124.                     gpu.fill(1, Y, 40, 1, " ")
  125.                 end
  126.                 gpu.setBackground(0x000000)
  127.                 if (Y > 2) and (Y ~= 17) then
  128.                     gpu.fill(1, Y-1, 40, 1, " ")
  129.                 end
  130.                 if (Y == 6) then
  131.                     gpu.set(17, 5, "_ _ _")
  132.                 end
  133.                 if (Y == 7) then
  134.                     gpu.set(16, 6, "| | | |_")
  135.                 end
  136.                 if (Y == 8) then
  137.                     gpu.set(16, 7, "| | | | |")
  138.                 end
  139.                 if (Y == 9) then
  140.                     gpu.set(15, 8, "_| | | | |")
  141.                 end
  142.                 if (Y == 10) then
  143.                     gpu.set(14, 9, "| | | | | |")
  144.                 end
  145.                 if (Y == 11) then
  146.                     gpu.set(14, 10, "| |       |")
  147.                 end
  148.                 if (Y == 12) then
  149.                     gpu.set(14, 11, "\\         |")
  150.                 end
  151.                 if (Y == 13) then
  152.                     gpu.set(15, 12, "\\        |")
  153.                 end
  154.                 if (Y == 14) then
  155.                     gpu.set(16, 13, "\\      /")
  156.                 end
  157.                 if (Y == 15) then
  158.                     gpu.set(17, 14, "|    |")
  159.                 end
  160.             os.sleep(0.1)
  161.             if (Y == 16) then
  162.                 break
  163.             end
  164.         end
  165. end
  166.  
  167. function CheckAPI()
  168.     if not fs.exists("lib/API_Config.lua") then
  169.         print("[API NOT FOUND: Config] Attempting To Download...")
  170.         shell.execute("pastebin get TPBGxPrZ /lib/API_Config.lua")
  171.     end
  172.     conf = require("API_Config")
  173.     ----LOADING CONFIG-----
  174.     if not conf.ConfigExists("Security.cfg") then
  175.         conf.EditConfig("Security.cfg", 1, "Using Redstone Block: ", "Boolean")
  176.         if (conf.GetConfig("Security.cfg", 1) == true) then
  177.             conf.EditConfig("Security.cfg", 2, "Redstone Output: ", "Direction")
  178.             conf.EditConfig("Security.cfg", 3, "Redstone Block Address: ", "Direction")
  179.         else
  180.             conf.EditConfig("Security.cfg", 2, "Redstone Output: ", "Facing")
  181.         end
  182.        
  183.     end
  184.     if conf.GetConfig("Security.cfg", 1) == nil then print("CONFIGURATION REQUIRED!") conf.EditConfig("Security.cfg", 1, "Using Redstone Block: ", "Boolean") end
  185.     if conf.GetConfig("Security.cfg", 2) == nil then
  186.         print("CONFIGURATION REQUIRED!")
  187.         if (conf.GetConfig("Security.cfg", 1) == true) then
  188.             conf.EditConfig("Security.cfg", 2, "Redstone Output: ", "Direction")
  189.         else
  190.             conf.EditConfig("Security.cfg", 2, "Redstone Output: ", "Facing")
  191.         end
  192.     end
  193.     if (conf.GetConfig("Security.cfg", 1) == true) then
  194.         if conf.GetConfig("Security.cfg", 3) == nil then print("CONFIGURATION REQUIRED!") conf.EditConfig("Security.cfg", 3, "Redstone Block Address: ", "String") end
  195.     end
  196.     Main()
  197. end
  198.  
  199. CheckAPI()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement