So I wanna know how I can make sure my scripts aren’t a bunch of nonsense, ugly code,
lazy code, placed the wrong places on the Explorer and all the bad things which you can do.
I’m not sure how I’ll have to do it, but I think it’s a great idea to have some tips from developers who are more experienced.
I’ve looked around for videos on how to organize scripts, but I feel like I need some more information.
Make sure you’re indenting is correct, indenting is putting tabs tab before each line depending on its scope, which makes things more beauiftul and understandable
--indented code, beautiful
while true do
wait()
if true then
print("hi")
end
end
--not indented, ew
while true do
wait()
if true then
print("hi")
end
end
Good variable naming, there are multiple ways to name variables
local VAR_NAME --all upper case
local varName --camel case
local VarName --pascal case
local varname --this looks bad
Also make sure the name are comprehensible, and don’t contain a lot of number and weird characters
Not sure if this is the wrong word, but avoid coupling at all costs.
When I was making a game, I had a lot of major issues with that. For instance, a game functionality that dictated something else, was inside of another game functionality.
I had a leaderboard mechanic that was also controlling the areas in which players are allowed to attack. If you design your game like this, you are going to have major problems down the line.
Good, it is also a great idea to vary between usages of names, for example, for important variables you can do VARIABLE but for something normal do variableName
@DaffyDavinko@Conejin_Alt I would disagree on putting your name and date and such at the top of the script. This only bloats the script and doesn’t add anything useful. Like who cares that I write a script at 3:52 PM that doesn’t contribute to my development. It’s obvious who wrote it, though @DaffyDavinko explaining the script’s purpose is a good idea.
--///Variables\\\--
local Var
local VarTrue
local Var1
local VarHello
--///Functions\\\--
Anbrick.Touched:connect(function()
print("Organized")
end)
Otherbrick.Touched:connect(function()
print("I like organize")
end)
--///Others\\\--
*Insert other things here
Basically do that,i honestly dont do,but you are asking on how you would do it,so ye,keep putting those
I would just recommend you to keep all your server scripts in ServerScriptsService as that keeps them organized, have a different name that’s simply describing the script and is easy to remember for all of your scripts in case you want to check them out later on, and just try and keep all the scripts together, for example, they could be in a Folder and not just everywhere, that will help organize it a little bit in Explorer.
By the way, this would work if you make an open sourced game, anybody who needs help on the script, he could see the name written in the script and message him for help.
Writing the date is useful too, to see if you have something outdated, for example, if print is replaced to Print at 3PM, if you go to your script, you might find that your script was updated at 2PM, and you can replace print to Print.
Writing information about your script is very important, if you are lost and you forgot what the script does, or if you give your game to another person, you can read the script information.
Big developers are doing this practice too, I think this is useful, commentaries are made for that reason. Give information.