Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. scanner = peripheral.wrap("right")
  2. timeInterval = 1
  3. logOutputFile = "playerLog"
  4. newLogTitle = "----Visitors----"
  5.  
  6. time = {m = -timeInterval, h = 0, d = 0}
  7.  
  8. while true do
  9.  
  10. players = scanner.getPlayers()
  11. time.m = time.m + timeInterval
  12.  
  13. if time.m >= 60 then
  14. time.m = time.m - 60
  15. time.h = time.h + 1
  16. if players[1] == nil then logger("Nobody is here.", false) end
  17. end
  18.  
  19. if time.h >= 24 then time.h = time.h - 24 time.d = time.d + 1 end
  20.  
  21. function logger(input, title)
  22.  
  23. logFile = fs.open(logOutputFile,"a")
  24. log = input
  25.  
  26. if title == false then
  27. log = "[" .. tostring(time.m) .. "/" .. tostring(time.h) .. "/" .. tostring(time.d) .. "] " .. input
  28. end
  29.  
  30. print(log)
  31. logFile.writeLine(log)
  32. logFile.close()
  33. end
  34.  
  35. if time.m == 0 and time.h == 0 and time.d == 0 then logger("\n" .. newLogTitle, true) end
  36.  
  37. for i=1,#players do
  38. for key,value in pairs(players[i]) do
  39. if key == "name" and value ~= nil then
  40.  
  41. logger(value, false)
  42.  
  43. end
  44. end
  45. end
  46. sleep(timeInterval * 60)
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement