Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What practices would you recommend for coding in ROBLOX Lua?

Asked by 4 years ago

I'm curious to see if people follow rules when coding in ROBLOX Lua. This can include things such as variable naming, code structure, etc.

1
Hi! There is an article on how roblox styles their code: https://roblox.github.io/lua-style-guide/ saSlol2436 716 — 4y
0
Thanks for the link. I'll check it out. iishadowflames 41 — 4y

1 answer

Log in to vote
3
Answered by 4 years ago
Edited 4 years ago

This question can receive a large number of correct answers. Truthfully, if it works, then it works. The only issue is how fast your result is given.

  • Structure

In my opinion, the average person on Roblox will use tab when structuring code to show different scopes and press their enter key to give a blank area in their script to help their eyes see what is where. As players get more advanced, they may begin to realize how helpful peppering your code with comments is so in the future, you can quickly notice what you were doing when you made it.

  • Variable Naming

Obviously, when naming a variable, you must do so in a way that gives a valid variable. Such as no numbers at the start. Also, the chances are that the variable in use has a name that shows what purpose the variable has, like Timer for a countdown. However, you can normally tell if a player has a background in other programming languages if their variables start with a lowercase for the first word, that capitals for the rest, such as myVariableName and variableName. These people are most likely use to their variable starting lower case and the type of their variable being capitalized. Employee employee; where the capital is the type Employee, the variable is employee.

  • Others

To be honest, you should never obfuscate code so other people cannot read what you intend the code to do. We humans (I assume you are human) write with upper-level programming languages meaning the code we type tend to be closer to the language we speak than it is to the language a machine speaks because we need to read and understand it. The purpose is to be read by people, so I have learned. Otherwise, we'd be using binary, which is faster than transforming any language into binary.


This question is very opinion based and everything I have said may be disagreeable to another person who may have more knowledge than I do. Simply strive to have readable code that runs as fast as you can make it. Oh and if it's deprecated, do not use it. Stop

1
This post is REALLY REALLY good ! I really loved it whenever you bolded the "Oh and if it's deprecated, do not use it. Stop." I see many professional developers use deprecated functions/methods (usually :connect, instead of :Connect) saSlol2436 716 — 4y
0
Thank you for the complement alphawolvess 1784 — 4y
Ad

Answer this question