Advertisement
stullick

ccProxCard

Mar 4th, 2015
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.43 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2. local auth_channel = 54321
  3. local reply_channel = 234
  4. local authCard = {}
  5. modem = peripheral.find("modem")
  6.  
  7. if not modem then
  8.     error("Modem not detected.")
  9. end
  10.  
  11. local sides = peripheral.getNames()
  12. for k,side in pairs(sides) do
  13.     if peripheral.getType(side) == "drive" then
  14.         rSide = side
  15.         reader = peripheral.wrap(rSide)              
  16.     end
  17. end
  18.  
  19. if not reader then
  20.     error("Card reader not detected.")
  21. end
  22.  
  23. modem.open(reply_channel)
  24.  
  25. while true do
  26.     term.clear()
  27.     term.setCursorPos(1,1)
  28.     term.setTextColor(colors.blue)
  29.     print("ProxyReader v1.5")
  30.     print("scs.mtweather.mil")
  31.     print("Authorized Users Only")
  32.     print("Access Attempts are Logged")
  33.     print("Please insert your Proxy Card...")
  34.  
  35.     diskHandle = os.pullEvent("disk")
  36.     authCard = disk.getID(rSide)
  37.     modem.transmit(auth_channel, reply_channel, authCard)
  38.     local event, modem_side, authChan, replyChan, message = os.pullEvent("modem_message")
  39.     if message == "valid" then
  40.         disk.eject(rSide)
  41.         term.setTextColor(colors.lime)
  42.         print("Welcome!")
  43.         print("Take your Proxy Card and enter.")
  44.         local redSides = {"left", "right", "top", "bottom", "back", "front"}
  45.         for i = 1, #redSides do
  46.             redstone.setOutput(redSides[i], true)
  47.         end
  48.         sleep(3)
  49.         for i = 1, #redSides do
  50.             redstone.setOutput(redSides[i], false)
  51.         end
  52.     else
  53.         disk.eject(rSide)
  54.         term.setTextColor(colors.red)
  55.         print("Not a valid proxy card.")
  56.         sleep(2)
  57.     end
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement