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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 16 Mar 2008 |
| Total Posts: 6139 |
|
|
| 25 Oct 2011 06:04 PM |
| Sorry, i dont use Chrome. :/ |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
| |
|
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 |
|
|
|
| 25 Oct 2011 08:59 PM |
| Whenever you start a new scope, derp |
|
|
| Report Abuse |
|
|