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: Indentation...

Previous Thread :: Next Thread 
Variniux is not online. Variniux
Joined: 22 Oct 2011
Total Posts: 201
25 Oct 2011 05:45 PM
When do I indent in my script?

My siggy... is bigger than yours.
Report Abuse
1Ra is not online. 1Ra
Joined: 02 May 2010
Total Posts: 2400
25 Oct 2011 05:45 PM
when you feel like indenting your script.

its not english class kid.
Report Abuse
Variniux is not online. Variniux
Joined: 22 Oct 2011
Total Posts: 201
25 Oct 2011 05:47 PM
@1Ra

Not what I meant.

My siggy... is bigger than yours.
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
25 Oct 2011 05:54 PM
Every time you have an end, the stuff before it should be indented.

Using some code I have as an example, this:

    getCFrame = function(object)
    if object:isA("BasePart") then
    return object.CFrame
    elseif object:isA("Model") and object.PrimaryPart then
    return getCFrame(object.PrimaryPart)
    else
    for _, o in ipairs(object:getChildren()) do
    local cf = getCFrame(o)
    if cf then
    return cf
    end
    end
    end
    end

Should be indented to this:
    
    getCFrame = function(object)
        --inside a function - indent!
        if object:isA("BasePart") then
            --inside an if - indent!
            return object.CFrame
        elseif object:isA("Model") and object.PrimaryPart then
            --inside an elseif - indent!
            return getCFrame(object.PrimaryPart)
        else
            --inside an else - indent!
            for _, o in ipairs(object:getChildren()) do
                --inside a for - indent!
                local cf = getCFrame(o)
                if cf then
                    --inside an if - indent!
                    return cf
                end
            end
        end
    end
Report Abuse
Variniux is not online. Variniux
Joined: 22 Oct 2011
Total Posts: 201
25 Oct 2011 05:59 PM
So is this correct?

function doMath()
local num = 5 * 5
if num == 25 then
local num2 = num * 2
if num2 == 50 then
print(num2)
else
print("Impossible!")
end
end
end

My siggy... is bigger than yours.
Report Abuse
Variniux is not online. Variniux
Joined: 22 Oct 2011
Total Posts: 201
25 Oct 2011 06:00 PM
My spaces were deleted! D:<

But I had them on lines 2, 4, 6, 8, 9, 10

My siggy... is bigger than yours.
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
25 Oct 2011 06:00 PM
Yep. Remember, most people can't see indentation in the forums. I can, because I have the roblox forum enhancer.
Report Abuse
crazyblox is not online. crazyblox
Joined: 16 Mar 2008
Total Posts: 6139
25 Oct 2011 06:00 PM
Tabs arn't Visible on the forums.
Use spaces instead.
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
25 Oct 2011 06:02 PM
Here is how I saw you indented it:

    function doMath()
         local num = 5 * 5
         if num == 25 then
              local num2 = num * 2
              if num2 == 50 then
                   print(num2)
              else
                   print("Impossible!")
              end
         end
    end

This is perfectly correct. There's one more time you should indent:

    local t = {
        --Line wrapping a table? indent!
        "A", "B", "C",
        "D", "E", "F"
    }
Report Abuse
Variniux is not online. Variniux
Joined: 22 Oct 2011
Total Posts: 201
25 Oct 2011 06:02 PM
@crazyblox

I did use spaces because tab was doing something totally random. No dice.

My siggy... is bigger than yours.
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
25 Oct 2011 06:03 PM
@crazyblock: Doesn't help. Get the [Roblox Forum Enhancer][1], and then they show up


  [1]: http://www.roblox.com/Forum/ShowPost.aspx?PostID=56847472
Report Abuse
Variniux is not online. Variniux
Joined: 22 Oct 2011
Total Posts: 201
25 Oct 2011 06:04 PM
Yes, that is how I indented it. From now on I'll do that because it looks much neater (and I'm pretty sure other languages require it).

My siggy... is bigger than yours.
Report Abuse
crazyblox is not online. crazyblox
Joined: 16 Mar 2008
Total Posts: 6139
25 Oct 2011 06:04 PM
Sorry, i dont use Chrome. :/
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
25 Oct 2011 06:06 PM
Actually, the only language that _requires_ it is python, IIRC. In all other languages, it's just a _really good idea_.
Report Abuse
Variniux is not online. Variniux
Joined: 22 Oct 2011
Total Posts: 201
25 Oct 2011 06:09 PM
Just installed ROBLOX Forum Enhancer. It is absolutely *amazing*.
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
25 Oct 2011 06:13 PM
Thanks.
Report Abuse
Variniux is not online. Variniux
Joined: 22 Oct 2011
Total Posts: 201
25 Oct 2011 08:48 PM
The only issue is that my siggy automator broke when I downloaded it. D:
Report Abuse
Cachinnation is not online. Cachinnation
Joined: 21 Aug 2011
Total Posts: 1797
25 Oct 2011 08:59 PM
Whenever you start a new scope, derp
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