Advertisement
CdoubleOK

SecCard Test

Oct 24th, 2024 (edited)
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.10 KB | None | 0 0
  1. local monitor = peripheral.wrap("front")
  2. local modem = peripheral.find("modem")
  3.  
  4. monitor.setCursorPos(1,1)
  5. monitor.setTextScale(0.5)
  6.  
  7. function monPrint(msg, bgc, tc)
  8. monitor.clear()
  9. monitor.setCursorPos(5,5)
  10. monitor.setTextColor(tc)
  11. monitor.setBackgroundColor(bgc)
  12. monitor.write(msg)
  13. end
  14.  
  15. while rs.getInput("front") == false
  16. do
  17. if disk.hasData("top") == false
  18. then
  19. term.clear()
  20. term.setCursorPos(1,1)
  21. print("Insert Card")
  22. monPrint("Insert", colors.yellow, colors.black)
  23. sleep(1)
  24. end
  25.  
  26. local id = disk.getID("top")
  27.  
  28. if disk.hasData("top") == true then
  29. modem.transmit(30, 31, id)
  30. modem.open(31)
  31. local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  32. while message == nil
  33. do
  34. print("Waiting..")
  35. end
  36.  
  37. if message == true then
  38. modem.close(31)
  39. monPrint("Granted", colors.green, colors.black)
  40. print("granted")
  41. disk.eject("top")
  42. sleep(1)
  43. rs.setOutput("right", true)
  44. sleep(2)
  45. rs.setOutput("right", false)
  46. else
  47. modem.close(31)
  48. monPrint("Denied", colors.red, colors.black)
  49. print("denied")
  50. disk.eject("top")
  51. sleep(2)
  52. end
  53. end
  54. end
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement