bobmarley12345

playerswhohaveenteredmybasedetectioninator

Oct 17th, 2020 (edited)
844
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sensor = peripheral.wrap("top")
  2. PlayerNamesTable = {}
  3.  
  4. function TableContains(table, item)
  5.     for key, value in pairs(table) do
  6.         if (value == item) then
  7.             return true
  8.         end
  9.     end
  10.  
  11.     return false
  12. end
  13.  
  14. function CheckPlayerNotAddedAndThenAdd(playerName)
  15.     if (TableContains(PlayerNamesTable, playerName) == false) then
  16.         table.insert(table, playerName)
  17.     end
  18. end
  19.  
  20. function IsEmpty(str)
  21.     return str == nil or str == ''
  22. end
  23.  
  24. function Main()
  25.     while true do
  26.         local playerNames = Sensor.getPlayerNames()
  27.  
  28.         for key, name in pairs(playerNames) do
  29.             CheckPlayerNotAddedAndThenAdd(name)
  30.         end
  31.  
  32.         term.clear()
  33.  
  34.         for key, playerName in pairs(PlayerNamesTable) do
  35.             print(playerName)
  36.         end
  37.  
  38.         os.sleep(2)
  39.     end
  40. end
  41.  
  42. Main()
RAW Paste Data