|
| 24 Mar 2015 09:06 AM |
| Hey guys! I've been scripting for about a month now and have gotten pretty good. (Currently making an Admin GUI Console kinda like a terminal...) I just wanted to see what you all thought were some best practices so I can not get into any bad habits lol Thanks in advance guys! |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2015 09:09 AM |
Best Practices:
1. Practice 2. Stumped? come here and learn.
that's what I do! |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2015 09:12 AM |
These are just a few of my opinions, only the ones that come to mind, and most of them are based on things I see done quite often on the forums.
Concatenating blank strings: local h = "" .. str .. num .. ""
Unnecessary and ugly comparisons: if firstchild ~= nil then if bool == true then
Using "elseif" where an "else" should be used: if bool == true then elseif bool == false then
I will tell you more if I think of any more, but for now have some links. http://wiki.roblox.com/index.php?title=Writing_Clean_Code http://blog.roblox.com/2012/05/using-wait-wisely/ |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2015 09:13 AM |
| Well ^ + Wiki, learn to use the wiki it's a valuable place of knowledge. You learn a lot from here and the wiki. Always check old posts before you post one on figuring out something. |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2015 09:13 AM |
Oh, I thought you said "Bad practices". My bad.
Avoiding those are good practices. |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2015 09:20 AM |
| Lol thanks guys! and I will definitely check out them links JarodOfOrbiter! |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2015 09:31 AM |
Do you also SSH into your Admin Terminal too?
Total Posts: 404 ---------- Not Found |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2015 09:37 AM |
use filtering
filteirng is luv filtering is life filtering is bae
⬡ |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2015 09:58 AM |
why would you tell him to use fe he cant script so ur only making it harder for him |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2015 10:06 AM |
if he's 'pretty good,' he should be able to use it
⬡ |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 24 Mar 2015 10:08 AM |
| @above not unless filtering breaks your game after you have spent 1000 lines of code in it. You can't just change it after that to suit the needs of FE. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 24 Mar 2015 10:09 AM |
| My bad habit is defining the wrong variables or none at all. Do not do that, it will ruin your life and time. |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2015 10:11 AM |
ofc, so start using filtering early and you'll never have to worry about that.
⬡ |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2015 10:32 AM |
| I would just like to say I can script (cough BothAngels cough) some advanced things are still out of reach but only been at this for like a month... I will take a look at filtering on the wiki and probably learn it pretty quick! |
|
|
| Report Abuse |
|
|
CrowClaws
|
  |
| Joined: 04 Jul 2010 |
| Total Posts: 4466 |
|
|
| 24 Mar 2015 10:40 AM |
Start using FIltering enabled. (It's much easier than it looks)
Seperate your code into >Variables >Functions >Code
|
|
|
| Report Abuse |
|
|
|
| 24 Mar 2015 10:42 AM |
| Oh well I already do that lol |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2015 10:45 AM |
"Seperate your code into >Variables >Functions >Code" Functions ARE variables.
Also, using local variables is a good practice. |
|
|
| Report Abuse |
|
|
CrowClaws
|
  |
| Joined: 04 Jul 2010 |
| Total Posts: 4466 |
|
|
| 24 Mar 2015 10:47 AM |
You know what i meant. but you don't want to put functions then some variables then functions.
|
|
|
| Report Abuse |
|
|
CrowClaws
|
  |
| Joined: 04 Jul 2010 |
| Total Posts: 4466 |
|
|
| 24 Mar 2015 10:48 AM |
| Oh yea use local variables whenever you can. When I was new i never did and it took some time getting use to it. |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2015 10:50 AM |
Well I do that too lol the only thing I was doing 'badly' was this:
if (someVar == true) then --stuff end
So i'll change that
@JarodOfOrbiter > That link on wait() was really useful! |
|
|
| Report Abuse |
|
|
notfruit
|
  |
| Joined: 21 Sep 2012 |
| Total Posts: 1386 |
|
|
| 24 Mar 2015 11:03 AM |
< sarcasm > brotip: make sure to always use OOP somehow, even if you don't need it. Remember, code like:
printer = new Printer() printer:print("Hello World!") printer:newLine()
is always better than:
print("Hello World!")
< /sarcasm >
I honestly don't know where this infatuation with OOP comes from.
If you want to *git gud* at programming, watch the SICP Lectures from MIT OpenCourseWare, and maybe read the book for free on the internet. Be careful, it has some heavy maths. |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2015 11:21 AM |
"printer = new Printer() printer:print("Hello World!") printer:newLine()
is always better than:
print("Hello World!")"
How is that better.. just doing print() is 1 line and easier because it just executes print() then instead of other uselessness
Total Posts: 404 ---------- Not Found |
|
|
| Report Abuse |
|
|
notfruit
|
  |
| Joined: 21 Sep 2012 |
| Total Posts: 1386 |
|
|
| 24 Mar 2015 11:50 AM |
@NovusTheory
did u not see my failed attempt at using html elements called "sarcasm"? Did u not see what was below? do u evn kno how 2 read omg i cant
It was sarcasm. |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2015 11:52 AM |
| Thanks. Oh by the way, if you read the comments there, you might facepalm or find it amusing or both. For me it was both. |
|
|
| Report Abuse |
|
|