Advertisement
Guest User

scan

a guest
May 20th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.42 KB | None | 0 0
  1. scanner = peripheral.wrap("top")
  2. timeInterval = 1
  3. logOutputFile = "playerLog"
  4. newLogTitle = "Neuer Log startet."
  5. monitor = peripheral.wrap("right")
  6. monitor.setCursorPos(1,1)
  7. monitor.clear()
  8. monitor.setTextColor(32)
  9.  
  10. time = {m = -timeInterval, h = 0, d = 0}
  11.  
  12. while true do
  13.  
  14.   players = scanner.getPlayers()
  15.   time.m = time.m + timeInterval
  16.  
  17.   monitor.clear()
  18.   monitor.setCursorPos(1,1)
  19.   monitor.write("Spieler Online:")
  20.  
  21.   for i=1,#players do
  22.   monitor.setCursorPos(1,i+2)
  23.   monitor.write(players[i].name)
  24.   end
  25.  
  26.  
  27.   if time.m >= 60 then
  28.     time.m = time.m - 60
  29.     time.h = time.h + 1
  30.     if players[1] == nil then logger("Niemand ist hier", false)
  31.     end
  32.   end
  33.  
  34.   if time.h >= 24 then time.h = time.h - 24 time.d = time.d + 1
  35.   end
  36.  
  37.   function logger(input, title)
  38.  
  39.     logFile = fs.open(logOutputFile,"a")
  40.     log = input
  41.    
  42.     if title == false then
  43.       log = "[" .. tostring(time.m) .. "/" .. tostring(time.h) .. "/" .. tostring(time.d) .. "] " .. input
  44.     end
  45.    
  46.     print(log)
  47.     logFile.writeLine(log)
  48.     logFile.close()
  49.   end
  50.  
  51.   if time.m == 0 and time.h == 0 and time.d == 0 then logger("\n" .. newLogTitle, true)
  52.   end
  53.  
  54.   for i=1,#players do
  55.     for key,value in pairs(players[i]) do
  56.       if key == "name" and value ~= nil and value ~= "Valerius2101" then
  57.  
  58.         logger(value, false)
  59.      
  60.       end
  61.     end
  62.   end
  63.   sleep(timeInterval * 5)
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement