- Joined
- May 9, 2014
- Messages
- 1,806
In the Lua version, there appears to be a lot of closure functions being employed (and generated) when using certain public functions such as
The chat system also appears to have functions which should behave as private functions, but are accessible everywhere (due to the global table
The for-loops in the system appear to have an unnecessary parameter, and also contains "magic" numbers.
You can remove the trailing 1 from the for-loop block and identify the purpose of the "magic" number by storing it as a "constant".
Indentation in the code might be a bit wonky.
EDIT:
Forgot to place this under Awaiting Update
print
, sendSystemMessage
, sendPlayerMessage
and so on. I suggest declaring them as their own functions.The chat system also appears to have functions which should behave as private functions, but are accessible everywhere (due to the global table
_G
. You can hide these functions from the global scope by doing the following:
Lua:
do
local function convertTime(...)
end
local function sizeCheck(...)
end
function sendSystemMessage(...)
end
end
The for-loops in the system appear to have an unnecessary parameter, and also contains "magic" numbers.
Lua:
-- An experienced modder would likely already know the meaning behind the numbers 0 and 23
-- after a careful inspection.
for pID = 0, 23, 1 do
-- do stuff
end
You can remove the trailing 1 from the for-loop block and identify the purpose of the "magic" number by storing it as a "constant".
Lua:
local MAX_PLAYERS = 24
MAX_PLAYERS = MAX_PLAYERS - 1
for pID = 0, MAX_PLAYERS do
-- do stuff
end
Indentation in the code might be a bit wonky.
EDIT:
Forgot to place this under Awaiting Update