cadergator10

Admin Diagnostic Tablet

Oct 19th, 2021 (edited)
83
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local cryptKey = {1, 2, 3, 4, 5}
  2. local diagPort = 180
  3.  
  4. local component = require("component")
  5. local event = require("event")
  6. local modem = component.modem
  7. local ser = require ("serialization")
  8. local term = require("term")
  9. local ios = require("io")
  10.  
  11. local departments = {"SD","ScD","MD","E&T","O5"}
  12. local cardReadTypes = {"access level","armory level","MTF","GOI","Security Pass","Department","Intercom","Staff"}
  13. local toggleTypes = {"not toggleable","toggleable"}
  14. local doorTypeTypes = {"Door Control","Redstone dust","Bundled Cable","Rolldoor"}
  15. local redSideTypes = {"bottom","top","back","front","right","left"}
  16. local redColorTypes = {"white","orange","magenta","light blue","yellow","lime","pink","gray","silver","cyan","purple","blue","brown","green","red","black"}
  17. local forceOpenTypes = {"False","True"}
  18. local bypassLockTypes = {"",""}
  19.  
  20. local function convert( chars, dist, inv )
  21.   return string.char( ( string.byte( chars ) - 32 + ( inv and -dist or dist ) ) % 95 + 32 )
  22. end
  23.  
  24.  
  25. local function crypt(str,k,inv)
  26.   local enc= "";
  27.   for i=1,#str do
  28.     if(#str-k[5] >= i or not inv)then
  29.       for inc=0,3 do
  30.     if(i%4 == inc)then
  31.       enc = enc .. convert(string.sub(str,i,i),k[inc+1],inv);
  32.       break;
  33.     end
  34.       end
  35.     end
  36.   end
  37.   if(not inv)then
  38.     for i=1,k[5] do
  39.       enc = enc .. string.char(math.random(32,126));
  40.     end
  41.   end
  42.   return enc;
  43. end
  44.  
  45. --// exportstring( string )
  46. --// returns a "Lua" portable version of the string
  47. local function exportstring( s )
  48.     s = string.format( "%q",s )
  49.     -- to replace
  50.     s = string.gsub( s,"\\\n","\\n" )
  51.     s = string.gsub( s,"\r","\\r" )
  52.     s = string.gsub( s,string.char(26),"\"..string.char(26)..\"" )
  53.     return s
  54. end
  55.  
  56. term.clear()
  57. print("Admin Diagnostic Tablet")
  58. print("Swipe an admin card on any security door to retrieve the door information")
  59. local num = 0
  60. while true do
  61.   if modem.isOpen(diagPort) == false then
  62.     modem.open(diagPort)
  63.   end
  64.  
  65.   local _, _, from, port, _, command, msg = event.pull("modem_message")
  66.   local data = msg
  67.   data = crypt(msg, cryptKey, true)
  68.   local diagInfo = ser.unserialize(data)
  69.   num = num + 1
  70.   term.clear()
  71.   print("Retrieved new door information # " .. num)
  72.   print("--------------------")
  73.   print("   Main Computer info:")
  74.   print("door status = " .. diagInfo["status"])
  75.   print("door type = " .. diagInfo["type"])
  76.   print("door update version = " .. diagInfo["version"])
  77.    
  78.   if diagInfo["status"] ~= "incorrect magreader" then
  79.         if diagInfo["type"] == "multi" then
  80.         print("number of door entries: " .. diagInfo["entries"])
  81.         print("door's key: " .. diagInfo["key"])
  82.     else
  83.         print("***")
  84.         print("***")
  85.     end
  86.   print("--------------------")
  87.   print("   Door's settings")
  88.     print("Pass type: " .. cardReadTypes[diagInfo["cardRead"] + 1])
  89.     if diagInfo["cardRead"] <= 1 then
  90.         print("Level read: " .. diagInfo["accessLevel"])
  91.     elseif diagInfo["cardRead"] == 5 then
  92.         print("Department: " .. departments[diagInfo["accessLevel"]])
  93.     else
  94.         print("***")
  95.     end
  96.     print("Door type: " .. doorTypeTypes[diagInfo["doorType"] + 1])
  97.     if diagInfo["doorType"] == 1 then
  98.         if diagInfo["type"] == "multi" then
  99.             print("Redstone Output Side: " .. redSideTypes[3])
  100.             print("***")
  101.         else
  102.             print("Redstone Output Side: " .. redSideTypes[diagInfo["redSide"] + 1])
  103.             print("***")
  104.         end
  105.     elseif diagInfo["doorType"] == 2 then
  106.         if diagInfo["type"] == "multi" then
  107.             print("Redstone Output Side: " .. redSideTypes[3])
  108.             print("Redstone Output Color: " .. redColorTypes[diagInfo["redColor"] + 1])
  109.         else
  110.             print("Redstone Output Side: " .. redSideTypes[diagInfo["redSide"] + 1])
  111.             print("Redstone Output Color: " .. redColorTypes[diagInfo["redColor"] + 1])
  112.         end
  113.     else
  114.         print("***")
  115.         print("***")
  116.     end
  117.     print("Toggle Door: " .. toggleTypes[diagInfo["toggle"] + 1])
  118.     if diagInfo["toggle"] == 0 then
  119.         print("Delay: " .. diagInfo["delay"])
  120.     else
  121.         print("***")
  122.     end
  123.     if diagInfo["forceOpen"] == nil then
  124.             print("Opens when forceopen called: " .. forceOpenTypes[2])
  125.     else
  126.             print("Opens when forceopen called: " .. forceOpenTypes[diagInfo["forceOpen"] + 1])
  127.     end
  128.     if diagInfo["bypassLock"] == nil then
  129.             print("Bypasses door lock: " .. forceOpenTypes[1])
  130.     else
  131.             print("Bypasses door lock: " .. forceOpenTypes[diagInfo["bypassLock"] + 1])
  132.     end
  133.   print("--------------------")
  134.   print("   Component Addresses")
  135.         if diagInfo["type"] == "multi" then
  136.             if diagInfo["doorType"] == 0 then
  137.                 print("Reader Address: " .. diagInfo["reader"])
  138.                 print("Doorcontrol Address: " .. diagInfo["doorAddress"])
  139.             elseif diagInfo["doorType"] == 3 then
  140.                 print("Reader Address: " .. diagInfo["reader"])
  141.                 print("RollDoor Address: " .. diagInfo["doorAddress"])
  142.             else
  143.                 print("Reader Address: " .. diagInfo["reader"])
  144.                 print("***")
  145.             end
  146.         else
  147.            print("***")
  148.            print("***")
  149.         end
  150.   else
  151.         if diagInfo["type"] == "multi" then
  152.         print("number of door entries: " .. diagInfo["entries"])
  153.         print("***")
  154.     else
  155.         print("***")
  156.         print("***")
  157.     end
  158.   print("--------------------")
  159.   print("   Door's settings")
  160.     print("***")
  161.     print("***")
  162.     print("***")
  163.     print("***")
  164.     print("***")
  165.     print("***")
  166.     print("***")
  167.     print("***")
  168.     print("***")
  169.   print("--------------------")
  170.   print("   Component Addresses")
  171.   print("***")
  172.   print("***")
  173.   end
  174.    
  175.   print("--------------------")
  176.   print("Scan another security door to retrieve it's door information")
  177. end
RAW Paste Data