Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --configuration
- writer = peripheral.wrap("right");
- reader = peripheral.wrap("left");
- redside = "back";
- label = "GateKey";
- data = "this is the gate key";
- range = 5;
- print("Simple in-secure RFID door!");
- print("Key name: "..label);
- print("Scanning Range "..range);
- function main()
- while true do
- --If there's a card in writer
- --and it is blank
- --and we're not currently writing
- if writer.isPresent() and (not writer.isCoded()) and (writer.getProgress() == -1) then
- --make a key
- writer.encode(data,label);
- end
- redstone.setOutput(redside,readerloop());
- os.sleep(.5); --allows redstone to move
- os.queueEvent("marker_event"); --clears event
- repeat
- e = os.pullEvent();
- until e == "marker_event";
- end
- end
- function readerloop()
- reader.scan(range);
- while true do --split from here
- e,p1,p2,p3,p4,p5 = os.pullEvent()
- if e == "rfid_detected" and p1 == data then
- return true;
- elseif e == "rfid_scan_done" then
- return false;
- end
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement