View difference between Paste ID: TAz2pygV and Bhky2xqr
SHOW: | | - or go back to the newest paste.
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.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
39+
      if key == "name" and value ~= nil and value ~= "Player's IGN" then
40
 
41
        logger(value, false)
42
      
43
      end
44
    end
45
  end
46
  sleep(timeInterval * 60)
47
end