Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --RFID_Door
- --initialize
- Reader = peripheral.wrap("top")
- code = {5, 8, 4, 3}
- data = {5, 8, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
- key_type = 0
- blockId = 0
- Key = {1, 2, 3, 4, 5, 6}
- --
- function Update()
- res = Reader.search()
- if (res) then
- Reader.select(res)
- Reader.auth(key_type, blockId, Key)
- Reader.write(blockId, data)
- Reader.deauth()
- print("writed!")
- for i=1, table.maxn(data ), 1 do
- print(i.."="..data[i].." true")
- end
- --
- Reader.auth(key_type, blockId, Key)
- ot = Reader.read(blockId)
- IsPassOk = false
- if (ot) then
- IsPassOk = true
- --print("find")
- for i=1, table.maxn(code), 1 do
- if (ot[i] == code[i]) then
- print(i.."="..ot[i].." true")
- else
- IsPassOk = false
- print(i.."="..ot[i].." false")
- end
- end
- end
- if (IsPassOk) then
- rs.setOutput("right", true)
- print("true")
- else
- rs.setOutput("right", false)
- print("false")
- end
- Reader.deauth()
- else
- print("NONE")
- end
- os.startTimer(1)
- end
- --Fisrt draw
- os.startTimer(1)
- repeat
- event,p1,p2,p3 = os.pullEvent()
- if (event=="rfid_detected") then
- print("p1="..p1.." p2="..p2.." p3="..p3)
- if p1 == doorPass then
- rs.setOutput(redstoneSide, true)
- lastTimer = os.startTimer(1)
- end
- elseif (event=="timer") then
- Update()
- elseif (event=="monitor_touch") then
- --p2 -- sets mouseWidth
- --p3 -- and mouseHeight
- TouchEvent(p2, p3)
- elseif (event=="redstone") then
- RedstoneEvent()
- end
- until event=="char" and p1==("q")
Advertisement
Add Comment
Please, Sign In to add comment