Advertisement
Guest User

playerLog

a guest
Apr 18th, 2014
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.65 KB | None | 0 0
  1.  
  2. --basic player logging
  3. --variables
  4. local sensorPos = 'top'
  5. local sensor = 'null'
  6. local playerList = 'null'
  7. local prevList = playerList
  8.  
  9. --Main program logic
  10.  
  11. function Main()
  12.   sensor = peripheral.wrap(sensorPos)
  13.   playerData = sensor.getPlayerNames()
  14.   prevList = playerList
  15.  
  16.   for _, name in pairs(playerData) do
  17.     playerList = name , ":"
  18.   end
  19.  
  20.   if(#playerData) then
  21.     if(playerList != prevList) then
  22.       print (playerList)
  23.     end
  24.   end
  25. end
  26.  
  27.  
  28. --initialise
  29. if(peripheral.isPresent(sensorPos)) then
  30.   print('success!')
  31.  
  32.   while true do
  33.     Main()
  34.     sleep(1)
  35.   end
  36. else
  37.   print('Please place a sensor ontop')
  38. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement