I'm creating a gaming server that allows Lua scripts. Basically, the script gets the server date and selects a text file based on that date. Each text file contains a list of names. The point of the script is to rename players a "fun" holiday name.
This is my initial code to populate a table and assign a name:
-- Get Names from selected Holiday file
local holFile = io.open(filePath .. holiday .. ".txt", "r");
local holidayNames = {}
for line in holFile:lines() do
table.insert (holidayNames, line);
end
-- Set Name to a random item in the Holiday Names table
randomItem = math.random(0, #holidayNames - 1)
Name = (holidayNames[randomItem])
I also added this part BEFORE the above code just to have a table populated with current names:
-- Get Current Players List
local currPlayers = io.open(filePath "players.txt", "r");
local currentPlayers = {}
for line in currPlayers:lines() do
table.insert (currentPlayers, line);
end
So basically, as I'm attempting to add items to holidayNames
, I want to see if they exist in currentPlayers
, first.