eniallator

scan 1.4.7

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