UnBuild
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 3233 |
|
|
| 27 May 2013 07:33 PM |
In scripts people like to use tabs (Or, "indenting") such as
while true do [TAB] wait(0.03) [TAB] print("Ok printed") end
Or
while true do [TAB] wait(0.03) [TAB] if true then [TAB] [TAB] print("Yep, true") [TAB] end end
Thats why there is a "auto indent" option
But sometimes the indents get messed up, or if you post it on the forums, they get removed.
My idea is pretty much this
You have this
https://twitter.com/CaptainSandbox/status/339176806894673920/photo/1
But you want it indented, but don't want to go back and add them all in yourself...So
https://twitter.com/CaptainSandbox/status/339176866848075776/photo/1
You click that, and your script becomes...
https://twitter.com/CaptainSandbox/status/339176943800967171/photo/1
This should also work if the current indents are wrong, such as
https://twitter.com/CaptainSandbox/status/339177000243691520/photo/1
Becomes
https://twitter.com/CaptainSandbox/status/339177059714736128/photo/1 |
|
|
| Report Abuse |
|
|
Dr01d3k4
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
|
| 27 May 2013 07:35 PM |
1) Your "fixed" indentation is wrong.
2) I wrote a plugin to do this:
local function getCount(lookIn, findString) local c = 0; local w = ""; for m1, m2 in lookIn:gmatch("([%w]*)"..findString.."(%w*)") do if ((m1 == "") and (m2 == "")) then c = c + 1; end end return c; end
local function autoFormat(c, tabChar) tabChar = tabChar or "\t"; local newCode = { }; local curTabAmount = 0; if (not c:match("^.-\n$")) then c = c.."\n"; end for ln in c:gmatch("(.-)\n") do ln = ln:gsub("^%s*(.+)", "%1"); local oldTabAmount = curTabAmount; local totCount = getCount(ln, "function") + getCount(ln, "if") + getCount(ln, "do") + getCount(ln, "repeat") - getCount(ln, "end") - getCount(ln, "until"); curTabAmount = curTabAmount + totCount; ln = tabChar:rep((totCount > 0) and oldTabAmount or curTabAmount)..ln; newCode[#newCode + 1] = ln; end newCode[#newCode + 1] = ""; return table.concat(newCode, "\n"); end
PluginManager():CreatePlugin() :CreateToolbar("Auto Tabber") :CreateButton("Auto Tabber", "Auto Tabber", "").Click:connect(function () local sc = game.Selection:Get()[1]; if (sc == nil) then print("Please select a script"); return; end if (not sc:IsA("BaseScript")) then print("Please select a script"); return; end sc.Source = autoFormat(sc.Source); print("Formatted game."..sc:GetFullName()); end); |
|
|
| Report Abuse |
|
|
UnBuild
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 3233 |
|
|
| 27 May 2013 07:37 PM |
"Your "fixed" indentation is wrong." Tell that to the auto indenter, not me
We shouldn't need a plugin for it. |
|
|
| Report Abuse |
|
|
dekkonot
|
  |
| Joined: 22 Dec 2010 |
| Total Posts: 6685 |
|
|
| 27 May 2013 07:48 PM |
I agree with this...
~ Linguam latinam est optimum ~ |
|
|
| Report Abuse |
|
|
|
| 27 May 2013 08:56 PM |
| Dat last end is tabbed wrongly. should be on the same line as the function it ends. |
|
|
| Report Abuse |
|
|
UnBuild
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 3233 |
|
|
| 27 May 2013 09:09 PM |
@Pop Again I blame auto indent qq |
|
|
| Report Abuse |
|
|
UnBuild
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 3233 |
|
| |
|
| |
|
|
| 28 May 2013 04:14 PM |
| Or upgrade forums to support posting of code? |
|
|
| Report Abuse |
|
|
| |
|
UnBuild
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 3233 |
|
|
| 30 May 2013 07:53 PM |
| http://www.youtube.com/watch?v=DkshOn0jRpw |
|
|
| Report Abuse |
|
|
|
| 30 May 2013 08:21 PM |
| am I the only 1 who doesn't tab when scripting? |
|
|
| Report Abuse |
|
|
UnBuild
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 3233 |
|
|
| 31 May 2013 11:16 AM |
@Cain I don't but I know others do, and those others don't like it non tabbed |
|
|
| Report Abuse |
|
|