Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor = peripheral.wrap("front")
- local modem = peripheral.find("modem")
- monitor.setCursorPos(1,1)
- monitor.setTextScale(0.5)
- function monPrint(msg, bgc, tc)
- monitor.clear()
- monitor.setCursorPos(5,5)
- monitor.setTextColor(tc)
- monitor.setBackgroundColor(bgc)
- monitor.write(msg)
- end
- while rs.getInput("front") == false
- do
- if disk.hasData("top") == false
- then
- term.clear()
- term.setCursorPos(1,1)
- print("Insert Card")
- monPrint("Insert", colors.yellow, colors.black)
- sleep(1)
- end
- local id = disk.getID("top")
- if disk.hasData("top") == true then
- modem.transmit(30, 31, id)
- modem.open(31)
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- while message == nil
- do
- print("Waiting..")
- end
- if message == true then
- modem.close(31)
- monPrint("Granted", colors.green, colors.black)
- print("granted")
- disk.eject("top")
- sleep(1)
- rs.setOutput("right", true)
- sleep(2)
- rs.setOutput("right", false)
- else
- modem.close(31)
- monPrint("Denied", colors.red, colors.black)
- print("denied")
- disk.eject("top")
- sleep(2)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement