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 » Scripting Helpers
Home Search
 

Re: Do you have to add spaces after you go to next line?

Previous Thread :: Next Thread 
2tallhank is not online. 2tallhank
Joined: 11 Jun 2010
Total Posts: 2075
26 Feb 2012 09:00 PM
[ Content Deleted ]
Report Abuse
2tallhank is not online. 2tallhank
Joined: 11 Jun 2010
Total Posts: 2075
26 Feb 2012 09:04 PM
[ Content Deleted ]
Report Abuse
Riderj is not online. Riderj
Joined: 15 Aug 2011
Total Posts: 1534
26 Feb 2012 09:05 PM
No, but it is convention to use tables when entering a new scope.

[[ 7/10 - Scripting| 4/10 - Building | 10/10 - Confused ]]
Report Abuse
Riderj is not online. Riderj
Joined: 15 Aug 2011
Total Posts: 1534
26 Feb 2012 09:06 PM
tabs*

Wow what possessed me to say tables :O

[[ 7/10 - Scripting| 4/10 - Building | 10/10 - Confused ]]
Report Abuse
2tallhank is not online. 2tallhank
Joined: 11 Jun 2010
Total Posts: 2075
26 Feb 2012 09:06 PM
[ Content Deleted ]
Report Abuse
Navydev is not online. Navydev
Joined: 21 Feb 2012
Total Posts: 274
26 Feb 2012 09:07 PM
You dont have to, but it makes it easier for you to read and for others as well. It also shows how functions are built up and were they are nested. Yes, you can have your code all on one line, which is useful for script building places, but not for scripts created in Studio.
Report Abuse
bl5eebryce is not online. bl5eebryce
Joined: 03 Aug 2009
Total Posts: 387
26 Feb 2012 09:08 PM
You don't have to but it makes it easier to read and look neater. Think of it as scripting etiquette.
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
26 Feb 2012 09:10 PM
As a rule of thumb, you tab the lines of code after each item that requires and end. This is not required, but people like to do it for two main reasons:

1) It makes the code more readable.
2) So you don't forget the ends.

Here's an example:

local x = 1
function PrintItem()
­ ­ ­ ­ print(x)
­ ­ ­ ­ x = x + 1
­ ­ ­ ­ ­if x == 5 then
­ ­ ­ ­ ­ ­ x = 1
­ ­ end
end
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
26 Feb 2012 09:10 PM
And of course, it all collapses again -_-


    local x = 1
    function PrintItem()
       print(x)
       x = x + 1
       if x == 5 then
          x = 1
       end
    end
Report Abuse
2tallhank is not online. 2tallhank
Joined: 11 Jun 2010
Total Posts: 2075
26 Feb 2012 09:57 PM
[ Content Deleted ]
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
26 Feb 2012 09:58 PM
Y U NO TAB IN ON if's not prints()'s.
Report Abuse
2tallhank is not online. 2tallhank
Joined: 11 Jun 2010
Total Posts: 2075
26 Feb 2012 10:00 PM
[ Content Deleted ]
Report Abuse
stravant is not online. stravant
Forum Moderator
Joined: 22 Oct 2007
Total Posts: 2893
26 Feb 2012 11:46 PM
It's when you hit the key that says `tab` on your keyboard, it's sort of like a space but more powerful in what it can be used for. In general it's used to format blocks of related stuff. Back in the old days you would use tabs to help format your documents, but now they're mainly just used in code because programs like word will do that for you these days.

The advantage of using tabs over spaces is that each person can set how wide a space each tab represents to fit their liking (for instance in Roblox you can do this in the studio settings), without having to edit the actual code.

In the code the tabbing makes it much easier to see what code belongs to each if statement and function etc, and makes it immediately obvious when an end is missing from one of the blocks in the code.
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
27 Feb 2012 07:22 AM
stravant has won this post again.
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
27 Feb 2012 04:39 PM
@stravant; Didn't know you could change tab space in settings. So changing that. Why do you start foruming now and not on xLEGOx?
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
27 Feb 2012 05:25 PM
xLEGOx's profile was swapped with Stravant's.
Report Abuse
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
27 Feb 2012 05:25 PM
@epicfail22
Idk y he started forming, but he got a name chabge from xlegox to starvent, becasue he is now a moderator, and there couldnt be "lego" in his name.
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
27 Feb 2012 05:26 PM
What I find funny is that he was a forumer on xLEGOx.
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
27 Feb 2012 05:26 PM
*Moderator
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
27 Feb 2012 06:45 PM
Yeah I knew that. I just never saw him on the forums when he was xLEGOx, and now I do when he's stravant.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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