My code’s getting longer and longer, and will probably reach the 250 line soon, and I would like to know if there’s any little tricks to hide a huge section of it or something. I already know these exist, but is there another way to hide more under a single one of these?
maybe you could put all your code inside a function, that way you can hide a lot
Well, yeah, I do, but I don’t put functions inside of other functions since that might cause unnecessary code to run. Gotta have it efficient, y’know
I got you bro
do
--Super long code right here
end
Roblox Studio, much like other IDEs, sets an area where code can be collapsed at the point where a new scope is created. We can manually create scopes using do
-end
blocks:
do
-- Code
end
This let you close user-defined sections of your code. Do know that 250 lines isn’t all that long, so the fact that you feel you need to move code out of the way is concerning. Maybe you have too much indentation? This can be solved through the never-nesting principle, which you can learn more about through a video titled “Why You Shouldn’t Nest Your Code” by CodeAesthetic. It could also be that your script is working towards too many goals. This goes against the Single Responsibility Principle (SRP). Make sure your scripts are only working towards one goal
Nothing wrong with a 250 line code … I’ve have scripts with over 1000 lines. If you like you can take parts of it and put it in a module.