svennp

speaking turtle greeting with rfid cards

Dec 2nd, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.72 KB | None | 0 0
  1. rfid = peripheral.wrap("top")
  2. speak = peripheral.wrap("left")
  3. distance = 3
  4. antiterm = false
  5.  
  6. known = {svenn = "SIA"}
  7.  
  8. function check(poo)
  9.   for k,v in pairs(known) do
  10.     if v == poo then
  11.       return k
  12.     end
  13.   end
  14.   return nil
  15. end
  16.  
  17. if antiterm then
  18.   os.pullEvent = os.pullEventRaw
  19. end
  20.  
  21. while true do
  22.   repeat
  23.     rfid.scan(distance)
  24.     event,param = os.pullEvent()
  25.     if event == "rfid_detected" then
  26.       ok = check(param)
  27.       if ok ~= nil then
  28.         speak.say("hello "..ok)
  29.         os.startTimer(2)
  30.         sleep(1.5)
  31.       else
  32.         speak.say("hello stranger")
  33.         os.startTimer(2)
  34.         sleep(1.5)
  35.       end
  36.     end
  37.   until event == "rfid_scan_done" or event == "timer"
  38. end
Advertisement
Add Comment
Please, Sign In to add comment