generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: bad habits for scripting in Lua:

Previous Thread :: Next Thread 
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
27 Feb 2015 12:28 PM
a = 'a'


a:Destroy();


Instance.new('Part', Workspace)

etc.

list others
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
27 Feb 2015 12:30 PM
http://wiki.roblox.com/index.php?title=Writing_Clean_Code
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
27 Feb 2015 12:51 PM
not putting local in front of variables
Report Abuse
KAAK82 is not online. KAAK82
Joined: 06 May 2014
Total Posts: 1166
27 Feb 2015 12:53 PM
function stuff() print('Hey') end; function otherStuff() print('Hello') end; function other() print('Hi') end

all in 1 Line -_-
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
27 Feb 2015 12:59 PM
@amanda

that was my first example, and in it was also ' ' instead of " "

and sometimes you /have/ to make them global
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
27 Feb 2015 01:01 PM
' ' instead of " "

why is this bad?
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
27 Feb 2015 01:02 PM
Using semicolons is not a bad practice. It actually makes your scripts faster.
Report Abuse
KAAK82 is not online. KAAK82
Joined: 06 May 2014
Total Posts: 1166
27 Feb 2015 01:05 PM
as amanda said, I dont see anything bad in '' :P
I use them, they're waaay more Comfortable for me XD
cos it's near the Enter Button XD
Report Abuse
NovusTheory is not online. NovusTheory
Joined: 14 Oct 2009
Total Posts: 4532
27 Feb 2015 01:12 PM
^ " and ' are both the same button...


CentOS-Web = /var/www/html/
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
27 Feb 2015 01:13 PM
' looks sloppy
Report Abuse
NovusTheory is not online. NovusTheory
Joined: 14 Oct 2009
Total Posts: 4532
27 Feb 2015 01:15 PM
Actually ' looks cleaner


CentOS-Web = /var/www/html/
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
27 Feb 2015 01:19 PM
' looks sloppy

does not

if hit.Name == 'DaPart' then
print 'Part Found'
end
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
27 Feb 2015 01:19 PM
if hit.Name == "DaPart" then
print 'Part Found'
end

" is wayyyy more cleaner in my opinion.
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
27 Feb 2015 01:20 PM
also your print

it kills me

print("stuff")

WAYYY CLEANER
Report Abuse
KAAK82 is not online. KAAK82
Joined: 06 May 2014
Total Posts: 1166
27 Feb 2015 01:25 PM
" Kills me XD
print("")
but here
print('')
waaay neater!

of course in my Opinion...
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
27 Feb 2015 01:26 PM
I completely disagree.

You may use quote marks if you so choose, however, it is not improper, less clean, or any less efficient to use single quotes(apostrophes).

And for that, I prefer them. Less effort, less eye strain(easier to read because there isn't as many marks).

If anything, double quotes is classic, but not more proper.
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
27 Feb 2015 01:28 PM
http://wiki.roblox.com/index.php?title=Writing_Clean_Code

It may be your opinion, but it's not proper.

"codeIsConfusing = true
if codeIsConfusing then
print("Man, this code is confusing.")
end"

> print("")
Report Abuse
ChiefDelta is not online. ChiefDelta
Joined: 05 Nov 2010
Total Posts: 13071
27 Feb 2015 01:30 PM
It is not clean to do print 'Thing.' and it is better practice to do print('Thing!')
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
27 Feb 2015 01:32 PM
"it is better practice to do print('Thing!')"

I can agree. I was arguing the single vs double quotes, not the parentheses.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
27 Feb 2015 01:33 PM
var = "yolo"

No local. Always use local, I have never seen a reason not to use local (on roblox) as long as you don't go over the limit.


local var = [[yolo]]

Only use [[]] if it's multi-lined, please


local x = {1; 2; 3; 4; 5; 6}

Use , in tables, it's much easier to read.


local helloWorld = "hi"

This one is ROBLOX only. The way you capitalize in ROBLOX should generally be HelloWorld.


local HelloWorld = "hi"

This one is outside-roblox. Doing this seems weird.


function(...) print(...) end

New lines are there for a reason, no need for 1 liners.


while wait() do

This is used a lot for little scripts, mainly for testing, but in fact, it's bad practice. I use it, however I didn't say I was a clean scripter XD. This will call wait() before the loop even executes the first time. Plus it's unnecessary if the loop has waits inside.


repeat wait() until (condition)

This is used to wait for a property to load or something. I mainly see it as repeat wait() until plr.Character. Usually there's no need for this. But it is acceptable if there's no other way. (CharacterAdded:wait() can be used instead)


local x = game.Players.warspyking
local y = workspace.Part

I hope you see what's wrong here! The variables have no meaning.


function func(x)
print(x)
end

Where da tabs at man? Coding should pretty much always have tabs in them.


workspace.Part.Effect.Script.Value.Value = workspace.Part.Effect.Script.Value.Value + (workspace.Part.Effect.Script.Value.Value - workspace.Model.Script.LocalScript.Value.Value)

Wow, no variables? Seriously?


getfenv(0).hello = "hi"

Okay dude, there's no reason to do this. Take out the whole first 11 characters XD



--I hope this is enough, at least for now.
Report Abuse
Skyman772 is not online. Skyman772
Joined: 20 Mar 2012
Total Posts: 9305
27 Feb 2015 01:33 PM
I use "'s because the difference is honestly miniscule.

Readability at the cost of a miniscule inefficiency is worth it for me.

When you start doing this?

while true do
print("dom");
end

THAT's when you're being an idiot.
Report Abuse
ChiefDelta is not online. ChiefDelta
Joined: 05 Nov 2010
Total Posts: 13071
27 Feb 2015 01:37 PM
"I was arguing the single vs double quotes"

That's silly.

What if you have to do:

print('"ChiefDelta is amazing", John said.')

That's the solution to needing types of quotes w/o escape characters.

Anyway I usually use single characters for methods now (out of habit) though I traditionally used double quotes.

It doesn't really matter.
Report Abuse
robotmega is not online. robotmega
Joined: 16 May 2009
Total Posts: 14084
27 Feb 2015 01:39 PM
Yea Then Capitalize Every Word For Extra Fast....

H='' -- not local so it runs faster! capitalized letters = faster = better
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
27 Feb 2015 01:47 PM
local variables are faster, don't think capitals even matter with speed.


x = 5
print(x)

local x = 5;
print(x);


The second is faster.
Report Abuse
ChiefDelta is not online. ChiefDelta
Joined: 05 Nov 2010
Total Posts: 13071
27 Feb 2015 02:55 PM
"local variables are faster"

No, not really.

Not really at all.

Unless we're talking about 10,000+ iterations there is basically not a single difference.

I've tested.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image