View difference between Paste ID: raz7cVpn 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()
10+
  players = scanner.getPlayerNames()
11
  time.m = time.m + timeInterval
12
  
13-
  if time.m >= 60 then 
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-
    if title == false then 
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-
    for key,value in pairs(players[i]) do
38+
39-
      if key == "name" and value ~= nil then
39+
40-
 
40+
41-
        logger(value, false)
41+
    logger(players[i])
42
  end
43-
      end
43+
44
  sleep(timeInterval * 60)
45
end