Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --a simple door lock with immibis peripherals mag-card
- os.loadAPI("StrUtils")
- function inFile(file, string)
- local f = fs.open(file,"r")
- local line
- repeat
- line = f.readLine()
- if string==line then
- f.close()
- return true
- end
- until not line
- f.close()
- return false
- end
- monitor = peripheral.wrap("monitor_0")
- mag = peripheral.wrap("mag card reader_0")
- monitor.setTextScale(1.5)
- while true do
- monitor.setBackgroundColor(colors.black)
- monitor.setTextColor(colors.blue)
- monitor.clear()
- monitor.setCursorPos(1,1)
- monitor.write("Swipe")
- monitor.setCursorPos(1,2)
- monitor.write("Card!")
- monitor.setCursorPos(3,4)
- monitor.setBackgroundColor(colors.blue)
- monitor.write(" ")
- monitor.setCursorPos(2,5)
- monitor.write(" ")
- monitor.setCursorPos(1,6)
- monitor.write(" ")
- monitor.setCursorPos(2,7)
- monitor.write(" ")
- monitor.setCursorPos(3,8)
- monitor.write(" ")
- local event,arg1,arg2,arg3 = os.pullEvent("mag_swipe")
- if inFile("//.keys", StrUtils.SHA1(arg1)) then
- monitor.setBackgroundColor(colors.green)
- monitor.clear()
- rs.setOutput("top",true)
- os.sleep(1.5)
- rs.setOutput("top",false)
- else
- monitor.setBackgroundColor(colors.red)
- monitor.clear()
- os.sleep(5)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement