Guest User

Security Card Reader

a guest
Apr 12th, 2013
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.28 KB | None | 0 0
  1. -- Security Card Reader
  2. -- Requires Security Card API
  3.  
  4. local lvl1 = "something"
  5. local lvl2 = "something"
  6. local pass = "password"
  7. local disklvl1, disklvl2, diskpass
  8.  
  9. if(not card)then
  10.     if(os.loadAPI("card")~=true)then
  11.         error("This program needs the security card API to function")
  12.     end
  13. end
  14.  
  15. term.clear()
  16. term.setCursorPos(1,1)
  17. while true do
  18.     print("Needs a security card to function")
  19.     print("Insert a security card to continue...")
  20.     --pullEventRaw stops them from pressing Ctrl-T to terminate
  21.     local event, side = os.pullEventRaw("disk")
  22.     if disk.hasAudio(side) then
  23.         print("Wrong disk type")
  24.         print("Press any key to continue...")
  25.         os.pullEventRaw("key")
  26.     else
  27.         break
  28.     end
  29. end
  30.  
  31. term.scroll(1)
  32. term.write("Reading")
  33. textutils.slowPrint("...")
  34. disklvl1,disklvl2,diskpass = card.getDiskLevel("bottom")
  35. if(disklvl1~=false)then
  36.     if(disklvl1==lvl1 and disklvl2==lvl2 and diskpass==pass)then
  37.         --Do Something example turns all rs outputs on for 5 seconds
  38.         for n,sSide in ipairs(rs.getSides())do
  39.             rs.setOutput(sSide,true)
  40.         end
  41.         sleep(5)
  42.         for n,sSide in ipairs(rs.getSides())do
  43.             rs.setOutput(sSide,false)
  44.         end
  45.     else
  46.         print("Wrong Security Card")
  47.     end
  48. else
  49.     print("Unable to read security card")
  50. end
  51. os.unloadAPI("card")
  52. --Good Programming Practice :)
Advertisement
Add Comment
Please, Sign In to add comment