Just a fun-little(ish) question I wanted to ask. :P
I took a look at Person299's Admin Commands script again, and looked at line 229 of the script: it was very interesting seeing how the first take-off admin commands blew up, especially when it came to lines 328-385.
The codes revolve around, for the code presented below, iterating through the string, around commas, checks if a player's name matches, then if the variable number-holder gets 1 player, it'll add the player to "players" (the variable-table-thing in the code); otherwise, it doesn't: the rest is pretty self-explanatory (imo).
However, are these considered good or bad written code? B/c they both, essentially, do:
...
local players = {} -- Code has been rewritten to look & be read much clearer
local onePlayer = nil
local playersWithMatchingNamesFound = 0
...
for i = 1, #commas do -- You can see this in line 349 & on in the admin; although, if you want Person299's of how to retrieve the positions around commas, it's lines 328-347
if player.Name == message:sub(commas[i]) then -- Doesn't look like this in the admin
onePlayer = player
playersWithMatchingNamesFound = playersWithMatchingNamesFound + 1
end
end
...
table.insert(players, player)
...
if playersWithMatchingNamesFound == 1 then
table.insert(players, onePlayer)
end
...
if #players ~= 0 then
return players
else
return 0
end
...
-- Later on in the code, which doesn't follow the above code
if playersWithMatchingNamesFound == 1 then
return {onePlayer}
elseif playersWithMatchingNamesFound > 1 then
return 0
elseif playersWithMatchingNamesFound == 0 then
return 0
end
But that's just a nutshell & clearer understanding of what goes on. (The official admin by Person299 is a cluttered, indented-less, elder-style type of code.)
Is this type of code a good idea, or a bad idea? Back then, I knew there were limitations & something like this had to be used, but in the modern day of lua, what is this considered? And does it hold up?

4 comments
whistles
Person299 and Kholtastrophe are the same person. The admin commands your speaking of are fairly good compared to many out there. The code is quite messy but it is possible to clean it up. Also keep in mind that these commands were not build with FE in mind. FE is now becoming a requirement.
Ok, problems: A. Kohl & Person are 2 different people. B. Good compared to others? At the time, it was the most re-uploaded model ever. C. Ik it can be cleaned up; that's not my question though.
D. I'm well aware that Kohl's & Person's admins aren't FE supported; however, again, that has nothing to do w/ my question.