Advertisement
cyber_Ahn

os.sensor.plugin

Aug 26th, 2016
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.69 KB | None | 0 0
  1. --works only with caw_os
  2. function sensor()
  3. file = fs.open("database/user.db","r")
  4. local fileData = {}
  5. local line = file.readLine()
  6. repeat
  7. table.insert(fileData,line)
  8. line = file.readLine()
  9. until line == nil
  10. file.close()
  11. out = "none"
  12. os.loadAPI("caAPI")
  13. local sensor_number = caAPI.get_hardware("openperipheral_sensor")
  14. if sensor_number ~= "openperipheral_sensor_off" then
  15. local sensor = peripheral.wrap(sensor_number)
  16. local names = sensor.getPlayers()
  17. for i=1, #names do
  18. for x=1, #fileData do
  19. user_s = fileData[x]
  20. user_sP = caAPI.split(user_s,"#")
  21. user_s = user_sP[1]
  22. user_ss = names[i]
  23. if user_s == names[i].name then
  24. out = "ok#"..names[i].name
  25. end
  26. end
  27. end
  28. end
  29. return out
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement