I’ve been working on this project of mine called CustomLuaCommands, a module script that was uploaded to roblox. I made it because most of the time, I find that I make functions in scripts that I also use in other scripts in other games. I thought if I could start to collect these functions and put them in one module script, it would be easier to write code because I wouldn’t have to write the same type of function again. That inspired me to make a lot more functions without actually needing them. After a while, the script had 1000+ lines of code. It’s version is 2.2 now, +0.1 every time I make a big change to the module. I was wondering if anybody else here wants to use it. It has some sales but I doubt they actually know how to script.
I notice that a lot of these functions seem to be default functions with different names. I also notice a few duplicate functions. Your filtering function would also get games shut down, as it simply just selects a random player to filter to.
This module is a project i’ve been working on for a long time now, so theres a chance I didn’t know about a method in a service or instance back when I wrote one of those functions you are talking about.
I’m talking about really odd functions, like:
function cmds.math.neg(num)
return math.abs(-num)
end
This just returns the same number? I’m so confused by its purpose. There’s also this function,
function cmds.PlayTween(tween)
tween:Play()
return tween
end
I can’t find it now, but there’s also cmds.Trash
which calls cmds.Deb
, which takes the same arguments as cmds.Trash
and plugs those in to game.Debris:AddItem()
. It’s evident you are aware of game.Debris:AddItem()
here.
Oh, um. I’ll have to delete math.neg I didn’t know I could just say -number. And things like cmds.Trash and cmds.PlayTween are just shorter ways of doing what it is intended to do.
There’s no reason to use cmds.Trash
or cmds.PlayTween
, their reference uses the same number of lines, and costs time which could be vital.
Tween:Play()
is faster than
cmds.PlayTween(Tween)
I have to note there’s a lot more functions like this, but there’s too many to list and talk about.
I guess you are right about that, but I thought it would look a little cleaner to use those instead if they were functions.
I like the idea of utility modules, but I was looking through the source and I have some questions about some of the implemented functions.
For starters, some of these functions are so simple in implementation that it doesn’t seem worth to implement. Things like loop print and kick seem pointless to me because the API that Roblox provides makes it easy enough to do those actions already. They’re basically just wrappers with no real purpose.
There’s also some errors that you can easily point out within the first few lines of code.
for _, obj in pairs(object:GetDescnendants()) do
It seems like a lot of code was lazily copy pasted from other functions without too much care for what was actually going on.
Then there’s just the straight up nonsense functions like rayclamp that dont provide anything useful back to the user.
cmds.math.rayclamp = function(num, min, max)
min = min or math.huge
max = max or math.huge
if type(num) ~= "number" then return 0 end
return num
end
It’s not actually doing anything to clamp the value to min or max and youre just better off using math.clamp.
Overall, I like the idea of the module but the implementation really needs some work. Your API is bloated and it would be a hassle to learn because of the broken and poorly documented functions.
Having code hidden from view in modules and making code slower/inefficient isn’t a priority under cleanliness in my opinion. I’m just saying, you really should’ve posted this in #help-and-feedback:code-review before posting this here.
Like I said before, some of the older functions are bad because I didn’t know as much about scripting as I do now.
Then why release the module here before fixing the broken functions? Just because you didn’t know something before doesn’t excuse the fact that you have broken stuff.
I wouldn’t say it’s broken, tho. I’m pretty sure it still works.
I have to note, again, object:GetDescnendants()
is broken code.
I mean, it’s just a typo. No biggie, i’ll fix it later.
Yes, it’s just a typo, but it’s a typo that would break someone’s code. This is important. I’d recommend posting this in #help-and-feedback:code-review and have this post deleted.
I like the idea you have behind this module, to eliminate some of the common code segments developers write when making a game. However, as @marfit says, a lot of these functions are redundant and the developer would be better off using the segment. Some of these functions look a bit random too, and don’t fit a lot of general developer needs.
- There’s a function to create an explosion with a random name (which I don’t understand why you’d need)
- Bloat of the
FindFirst...
andGetChildren/Descendant...
functions. A lot of these seem extremely situational. - A lot of these functions wrap a pre-existing method, such as
Kick
,Trash
, andFindFirstPlayer
.
I feel the module table itself is also extremely polluted with all these functions mixed in with other indices, which makes it harder to navigate the module.
You should really clean this up and categorize things before releasing this.
The whole module isn’t broken. But there’s clearly functions that do not work because of spelling mistakes. Your first 3 functions in the module will not work because they all share the same misspelling of “Descendants” as pointed out. My suggestion is to do more rigorous testing beforehand to minimize issues down the line.
Theres over 1300 lines of code, I can’t possibly just them all by myself…
A lot of the functions are “situational” because they are built off of functions I used in some of my past scripts.
That issues lies in the API bloat that @megukoo and I were referencing. Those 1300 lines are filled with functions that you may or may not need because its easy enough to do through Roblox’s API.