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
 

Efficient Code?

Previous Thread :: Next Thread 
Lecturous is not online. Lecturous
Joined: 17 Aug 2013
Total Posts: 1096
10 Oct 2015 09:10 PM
I know how to code, but I think my code isn't efficient.
Can you guys help my code be more efficient/show me examples of efficient code?

~ [ E> ] My heart is metallic, but it still has feelings. ~
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
10 Oct 2015 09:15 PM
Local variables
Numeric for loops
Events instead of constant looping
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
10 Oct 2015 09:17 PM
How are numeric for loops more efficient than pairs or similar?
Report Abuse
gangman67 is not online. gangman67
Joined: 04 Jun 2011
Total Posts: 798
10 Oct 2015 09:32 PM
@Lec, Idk cnt yelled at me for saying that before but never provided proof of why but the example I used it for was getting children and here > http://wiki.roblox.com/index.php?title=API:Class/Instance/GetChildren Roblox even recommends Generic loops over numerical ones http://wiki.roblox.com/index.php?title=Generic_for that will explain more on generic loops, But really It just depends on what you are doing with the loop like numerical loops should just be used with stuff that doesn't have a iterator other than that I would stick to generic loops.
Report Abuse
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
10 Oct 2015 09:33 PM
You know how much of the time you need to clone a scripted object multiple times in one place? Well, I use one script in the ServerScriptService to search for specific objects in the workspace and assign event listeners and functions to each of the same creed. Maybe you could try that?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
10 Oct 2015 09:40 PM
I did explain it, you probably just didn't understand it.
Generic for loops by nature are slower, they require function calls each iteration and some iterators are not stateless, causing overhead.
Report Abuse
gangman67 is not online. gangman67
Joined: 04 Jun 2011
Total Posts: 798
10 Oct 2015 09:46 PM
I can see why it would use more resources now but why does the wiki recommend it over numerical for loops?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
10 Oct 2015 09:47 PM
Because the wiki is stupid.
Report Abuse
gangman67 is not online. gangman67
Joined: 04 Jun 2011
Total Posts: 798
10 Oct 2015 09:49 PM
Lol, Logic!
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