Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sensor = peripheral.wrap("top")
- PlayerNamesTable = {}
- function TableContains(table, item)
- for key, value in pairs(table) do
- if (value == item) then
- return true
- end
- end
- return false
- end
- function CheckPlayerNotAddedAndThenAdd(playerName)
- if (TableContains(PlayerNamesTable, playerName) == false) then
- table.insert(table, playerName)
- end
- end
- function IsEmpty(str)
- return str == nil or str == ''
- end
- function Main()
- while true do
- local playerNames = Sensor.getPlayerNames()
- for key, name in pairs(playerNames) do
- CheckPlayerNotAddedAndThenAdd(name)
- end
- term.clear()
- for key, playerName in pairs(PlayerNamesTable) do
- print(playerName)
- end
- os.sleep(2)
- end
- end
- Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement