A Roblox Community
Would you like to react to this message? Create an account in a few clicks or log in to continue.

A Roblox Community

A community of Robloxians who want to learn to script and build on Roblox Studio.
 
HomeLatest imagesRegisterLog in
If you're a experienced coder make some tutorials! It would really help the site grow.
Make sure you read the rules(Which can be found by clicking here)
If you're a beginner at coding, try some tutorials.
We have many Moderators/Admins watching this site. Contact them with Questions.
Let us know what your favorite sport is. By clicking here to vote (Click here)
This site is becoming inactive. Lets make it active.
Log in
Username:
Password:
Log in automatically: 
:: I forgot my password
Top posters
blueymaddog
Improve Coding Vote_lcapImprove Coding Voting_barImprove Coding Vote_rcap 
naknak
Improve Coding Vote_lcapImprove Coding Voting_barImprove Coding Vote_rcap 
Supernapalm
Improve Coding Vote_lcapImprove Coding Voting_barImprove Coding Vote_rcap 
m27frogy
Improve Coding Vote_lcapImprove Coding Voting_barImprove Coding Vote_rcap 
slayer9365
Improve Coding Vote_lcapImprove Coding Voting_barImprove Coding Vote_rcap 
myrco919
Improve Coding Vote_lcapImprove Coding Voting_barImprove Coding Vote_rcap 
branefreez
Improve Coding Vote_lcapImprove Coding Voting_barImprove Coding Vote_rcap 
ninga95
Improve Coding Vote_lcapImprove Coding Voting_barImprove Coding Vote_rcap 
CloneTrooper787
Improve Coding Vote_lcapImprove Coding Voting_barImprove Coding Vote_rcap 
raboy117
Improve Coding Vote_lcapImprove Coding Voting_barImprove Coding Vote_rcap 
Top posting users this month
No user
Latest topics
» Where to go from here.
Improve Coding EmptySeptember 14th 2020, 1:20 pm by MrNicNac

» Send me an Email
Improve Coding EmptySeptember 14th 2020, 1:16 pm by MrNicNac

» [v1.6.0.0] Lua Script Obfuscator [No Bytecode]
Improve Coding EmptyJuly 6th 2015, 7:38 pm by m27frogy

» New Site Possibly
Improve Coding EmptyJuly 6th 2015, 4:16 pm by m27frogy

» Ambassador!
Improve Coding EmptyApril 15th 2015, 11:40 pm by naknak

» Boop - Tag
Improve Coding EmptyApril 13th 2015, 9:46 pm by naknak

» Vip Class Script
Improve Coding EmptyApril 13th 2015, 4:54 pm by naknak

» Who's active?!
Improve Coding EmptyApril 13th 2015, 4:52 pm by naknak

» Genesis Point
Improve Coding EmptyJuly 17th 2014, 7:04 pm by branefreez

» Reward System
Improve Coding EmptyJuly 17th 2014, 5:41 am by m27frogy

» Script Request
Improve Coding EmptyJuly 10th 2014, 11:43 am by naknak

» local scripts?
Improve Coding EmptyJuly 10th 2014, 11:39 am by naknak

» Project: Reconstruction [Died]
Improve Coding EmptyJuly 10th 2014, 11:36 am by naknak

» Hi. I am new here
Improve Coding EmptyApril 26th 2014, 4:01 pm by altshiftkey

» What's your favorite sport?
Improve Coding EmptyJanuary 1st 2014, 2:13 pm by m27frogy

» FlashLight Script
Improve Coding EmptyJanuary 1st 2014, 2:11 pm by m27frogy

» Gun Making! [READ DESC]
Improve Coding EmptyJanuary 1st 2014, 2:10 pm by m27frogy

» Hi, I am new here!
Improve Coding EmptyNovember 26th 2013, 3:33 pm by Keanu73

» Improve Coding
Improve Coding EmptyOctober 26th 2013, 1:12 pm by pook03

» Simple Button
Improve Coding EmptySeptember 1st 2013, 6:19 pm by branefreez


 

 Improve Coding

Go down 
5 posters
Go to page : 1, 2  Next
AuthorMessage
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

Improve Coding Empty
PostSubject: Improve Coding   Improve Coding EmptyJanuary 20th 2011, 7:39 pm

I'm not sure if this belongs here, but anyway.

There are many ways to code. Some better than others. For example, a recent project of mine has to communicate and interact across the Workspace with other scripts constantly. The problem? I had two options. One would be to use multiple scripts for the same amount of work, creating more lag. My choice? I used coroutines, consecutive functions, and 'shared' to store data. My choice was much less laggy and kept the Workspace looking usable. But on to improving your scripts.
-------------------------------------------------------------------------------------------------------


1. Instead of while true do wait(), I always use while wait() do. This saves you a decent amount of space eventually if your script has many while-do statements.

2. Pretend we were trying to insert a message.
When using Instance.new, never do this except for readablity:
Code:
obj = Instance.new("Message")
obj.Parent = Workspace
obj.Text = "Test"
A way to condense this into a small amount is to take advantage of an arguement some people ignore.
Code:
Instance.new("Message",Workspace).Text = "Test"

3. Take advantage of coroutines to prevent wasted script space. For example, instead of having one script checking for newly inserted parts, and another changing the time, we can combine them
Code:
coroutine.resume(coroutine.create(function ()
while wait() do
--time changer
end
end))
function function1(a)
if a.className == "Part" then
--blah
end end
game.Workspace.ChildAdded:connect(function1)

4. Remove whitespace and comments. The script has to still read whitespace and comments, so it results in wasted space and script time. If you use these as organization, remove them once your done.

5. Local vairables are called much faster than non-local. If you only need a variable for a small amount of code, just make it local to that function.
Code:
d = "hi"
function hi()
print(d)
end
--instead of that ^ do this
function hi()
local d = "hi"
print(d)
end


I'm not done. I just got tired of typing for now


Last edited by naknak on January 22nd 2011, 1:38 pm; edited 1 time in total
Back to top Go down
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 25

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyJanuary 22nd 2011, 3:19 am

don't forget local variables, they're called much faster than global!
Back to top Go down
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyJanuary 22nd 2011, 1:34 pm

I'll add it in, thanks!
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter
avatar


Posts : 393
Join date : 2011-01-17

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyJanuary 22nd 2011, 4:11 pm

hey! i was the one who said that first! jk lol. no rly. i was.
Back to top Go down
http://hackthissite.org
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyJanuary 22nd 2011, 4:33 pm

I know, but I forgot.
Back to top Go down
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 25

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyJanuary 23rd 2011, 4:32 am

i already knew about local variables being called faster than normal variables before you told us.
Back to top Go down
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyJanuary 23rd 2011, 3:09 pm

The only reason I don't use them is because it broke one of my more lengthy scripts and I somehow can't fix it now...
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter
avatar


Posts : 393
Join date : 2011-01-17

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyJanuary 23rd 2011, 7:48 pm

oh
Back to top Go down
http://hackthissite.org
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyJanuary 23rd 2011, 9:08 pm

I fixed it finally! My brain was too numbed to fix it last night.
Back to top Go down
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 25

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyJanuary 26th 2011, 8:36 am

lawl
Back to top Go down
m27frogy
The Garbageman
m27frogy


Posts : 336
Join date : 2011-06-23

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyJune 30th 2011, 11:35 am

XD
Back to top Go down
m27frogy
The Garbageman
m27frogy


Posts : 336
Join date : 2011-06-23

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyJune 30th 2011, 11:41 am

I would disagree with your comment whitewash though. What happens if someone else wants to edit your Free model script and no comments!! Major pain. Also, how much time is actually taken up reading these comments? 0.001 of a second? Plus, the Roblox admins sure didn't think comments were bad, their scripts are full of them! If the source code for the website has 'em everywhere! Overall, doing so would violate one of the many rules for good, strong, structured programming. Make it simple and be able to come back to it several months later and be able to quickly figure out how to fix it, instead of having to figure out how the script works all over again!
Back to top Go down
m27frogy
The Garbageman
m27frogy


Posts : 336
Join date : 2011-06-23

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyJune 30th 2011, 11:42 am

I was tought programming from a colledge aproach, even though I'm not even close to colledge. All the resources I read made it very clear that there had to be comments in any good code that was meant to be usable by anyone other than you.
Back to top Go down
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyJune 30th 2011, 11:47 am

Very true. I am probably going to start using comments again, I lost track of some of the things I made so I have to re-figure them out.
Back to top Go down
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 25

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyFebruary 4th 2012, 8:07 am

I think lua would precompile the syntax and would remove things like comments before it is run, so I doubt it would make a difference...
Back to top Go down
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyFebruary 5th 2012, 1:37 am

That, I don't know. I heard somewhere it makes it faster, but it doesn't make it easier to return to later.
Back to top Go down
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 25

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyFebruary 5th 2012, 6:48 am

lol my admin commands has a line with so many whitespaces that it reachs the limit for a line :P (I was trying to hide some code where people don't look)
Back to top Go down
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyFebruary 11th 2012, 1:28 am

Obfuscate the parts you don't want touched. Or the whole thing.
Back to top Go down
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 25

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyFebruary 11th 2012, 7:50 am

meh, I'm gonna make it free source to edit code, but I'm gonna add a delayed virus into it so it's a trial version that works for 1 week after inserting it and then it removes itself and the map! mwhahahaha, never trust my huge open source stuff >:D
Back to top Go down
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyFebruary 11th 2012, 5:05 pm

Ctrl+A, find where the blue space looks suspiciously long, scroll to the end, delete.
Back to top Go down
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 25

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyFebruary 16th 2012, 2:32 am

dang X_X but most noobs wont even open the script apart from inserting their name into it >:D
Back to top Go down
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyFebruary 19th 2012, 11:22 pm

That is true. But you want to hit as many people as possible.
Back to top Go down
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 25

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyFebruary 22nd 2012, 6:44 am

yea, I'll just encrypt every thing except for the admin lists. (in the encrypted part of the code if will insert my name >:)
Back to top Go down
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyFebruary 23rd 2012, 12:08 am

Obfuscate, don't encrypt. Encryption can be reversed and stolen, obfuscate can be only slightly reversed and is not worth the effort to steal.
Back to top Go down
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 25

Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding EmptyFebruary 25th 2012, 3:53 pm

wait, what the difference???? O_O
Back to top Go down
Sponsored content





Improve Coding Empty
PostSubject: Re: Improve Coding   Improve Coding Empty

Back to top Go down
 
Improve Coding
Back to top 
Page 1 of 2Go to page : 1, 2  Next
 Similar topics
-
» How Can I Improve This Script?

Permissions in this forum:You cannot reply to topics in this forum
A Roblox Community :: Tutorials and Resources :: Advanced-
Jump to: