[Lua] Autoit Coded Indentation Fixer menu

User Tag List

Results 1 to 6 of 6
  1. #1
    mmhelm's Avatar Member
    Reputation
    25
    Join Date
    Aug 2007
    Posts
    147
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Lua] Autoit Coded Indentation Fixer

    Its pretty simple, just drag and drop your Lua onto the exe. Included sourcecode.

    tidy.au3
    Code:
    $section = IniRead(@ScriptDir&"\tidy.ini", "tidy", "Section", "")
    $backup = IniRead(@ScriptDir&"\tidy.ini", "tidy", "CreateBackUp", "")
    $TabAdd = StringSplit(IniRead(@ScriptDir&"\tidy.ini", $section, "TabAdd", ""), ";")
    $TabRem = StringSplit(IniRead(@ScriptDir&"\tidy.ini", $section, "TabRemove", ""), ";")
    $TabSpec = StringSplit(IniRead(@ScriptDir&"\tidy.ini", $section, "TabSpecial", ""), ";")
    
    
    
    If $CMDLine[0] > 0 Then
        $file = ""
        For $i = 1 To $CMDLine[0]
            $file &= $CMDLine[$i] & " "
        Next
        $file = StringTrimRight($file, 1)
    Else
        $file = FileOpenDialog("Open File",@ScriptDir,$section&" (*."&$section&")"&"|All Files (*.*)")
        If @error Then
            exit
        EndIf
    EndIf
    
    $TabLevels = 0
    $SpecialLine = 0
    
    ;~ $file = @ScriptDir & "\lol.txt"
    
    $data = StringSplit(StringReplace(FileRead($file), @TAB, " "), @CRLF, 1)
    
    If $backup = 1 Then
        DirCreate("backup")
        FileMove($file,@WorkingDir&"\backup\",1)
    EndIf
    
    $New = ""
    For $i = 1 To $data[0]
        $data[$i] = _RemoveSpacesAndTabs($data[$i])
        $data[$i] = _AddRemoveTabLevels($data[$i])
        $New &= $data[$i] & @CRLF
    Next
    
    FileDelete($file)
    FileWrite($file,$New)
    
    ;~ ClipPut($New)
    
    Func _RemoveSpacesAndTabs($sLine)
        While StringLeft($sLine, 1) = @TAB Or StringLeft($sLine, 1) = " "
            $sLine = StringTrimLeft($sLine, 1)
        WEnd
        Return $sLine
    EndFunc   ;==>_RemoveSpacesAndTabs
    
    Func _AddRemoveTabLevels($sLine)
        ;==> Add spaces
        For $i = 1 To $TabAdd[0]
            $sLine = StringReplace($sLine, $TabAdd[$i] & "f(", $TabAdd[$i] & "f (")
        Next
        For $i = 1 To $TabRem[0]
            $sLine = StringReplace($sLine, $TabRem[$i] & "f(", $TabRem[$i] & "f (")
        Next
        For $i = 1 To $TabAdd[0]
            $sLine = StringReplace($sLine, $TabAdd[$i] & "r(", $TabAdd[$i] & "r (")
        Next
        For $i = 1 To $TabRem[0]
            $sLine = StringReplace($sLine, $TabRem[$i] & "r (", $TabRem[$i] & "r (")
        Next
            For $i = 1 To $TabAdd[0]
            $sLine = StringReplace($sLine, $TabAdd[$i] & "e(", $TabAdd[$i] & "e (")
        Next
        For $i = 1 To $TabRem[0]
            $sLine = StringReplace($sLine, $TabRem[$i] & "e(", $TabRem[$i] & "e (")
        Next
            For $i = 1 To $TabAdd[0]
            $sLine = StringReplace($sLine, $TabAdd[$i] & "o(", $TabAdd[$i] & "o (")
        Next
        For $i = 1 To $TabRem[0]
            $sLine = StringReplace($sLine, $TabRem[$i] & "o(", $TabRem[$i] & "o (")
        Next
        ;RemoveDopuble spaces
        $sLine = StringReplace($sLine, "  ", " ")
        $Tabs = ""
        For $i = 1 To $TabLevels
            $Tabs &= @TAB
        Next
        $TabLevelsCurrent = $TabLevels
        _SetTabLevels($sLine)
        If $TabLevelsCurrent > $TabLevels Then
            $Tabs = ""
            For $i = 1 To $TabLevels
                $Tabs &= @TAB
            Next
        EndIf
        If $SpecialLine = 1 Then
            $SpecialLine = 0
            Return StringTrimLeft($Tabs & $sLine, 1)
        Else
            Return $Tabs & $sLine
        EndIf
    EndFunc   ;==>_AddRemoveTabLevels
    
    Func _SetTabLevels($sLine)
        $Words = StringSplit($sLine, " ")
        For $i = 1 To $TabAdd[0]
            If $Words[1] = $TabAdd[$i] Then
                For $n = 1 To $TabRem[0]
                    If $Words[0] > 1 Then
                        If $Words[$Words[0]] = $TabRem[$n] Then
                            $TabLevels -= 1
                        EndIf
                    EndIf
                Next
                $TabLevels += 1
            EndIf
        Next
    
        For $i = 1 To $TabRem[0]
            If $Words[1] = $TabRem[$i] Then
                If $SpecialLine = 1 Then
                    $TabLevels -= 2
                    $SpecialLine = 0
                Else
                    $TabLevels -= 1
                EndIf
            EndIf
        Next
    
        For $i = 1 To $TabSpec[0]
            If $Words[1] = $TabSpec[$i] Then
                $SpecialLine = 1
            EndIf
        Next
        If $TabLevels < 0 Then
            $TabLevels = 0
        EndIf
    EndFunc   ;==>_SetTabLevels
    tidy.ini
    Code:
    [Tidy]
    ;Section name  used to read keywords
    Section=Lua
    ;CreateBackUp=1 will create back up of original file, 0 will owerwrite
    CreateBackUp=0
    
    ;Section for lua ascript
    [Lua]
    TabAdd=function;if;do;for;while
    TabRemove=end
    TabSpecial=else;elseif;case
    Download

    (do I need to include a scan with the source included? - will anyway )
    VirusTotal - Free Online Virus, Malware and URL Scanner

    Looks like some false positives, but don't trust me - compile it yourself.

    [Lua] Autoit Coded Indentation Fixer
  2. #2
    Terrorblade's Avatar Contributor I spent 5k CC and all I got was this user title
    CoreCoins Purchaser
    Reputation
    153
    Join Date
    Oct 2010
    Posts
    312
    Thanks G/R
    6/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    TBH I lol'd at this xD, but it actually seems pretty nice.
    Stuff & Things

  3. #3
    Goggy96's Avatar Sergeant
    Reputation
    1
    Join Date
    Mar 2010
    Posts
    46
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wait whats that in the Virus check?

    It says: Trojan-Downloader.Win32.Small

    WTH?

  4. #4
    stoneharry's Avatar Moderator Harry

    Authenticator enabled
    Reputation
    1613
    Join Date
    Sep 2007
    Posts
    4,554
    Thanks G/R
    151/146
    Trade Feedback
    0 (0%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Goggy96 View Post
    Wait whats that in the Virus check?

    It says: Trojan-Downloader.Win32.Small

    WTH?
    There's no virus in the source code.

    tidy.exe has probably been used as a filename before, so it uses the results from last time a tiny.exe was scanned.

  5. #5
    myran2's Avatar Contributor

    Reputation
    130
    Join Date
    Dec 2008
    Posts
    475
    Thanks G/R
    3/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Virus Scanners hate AutoIT.
    So if it's been made with autoit, 95% of the time, it's going to report that there's something bad in the executable when it's actually 100% clean.

  6. #6
    Goggy96's Avatar Sergeant
    Reputation
    1
    Join Date
    Mar 2010
    Posts
    46
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah ok. Thanks for the Info

Similar Threads

  1. LUA Protected CODE
    By vabatta in forum WoW Bots Questions & Requests
    Replies: 6
    Last Post: 04-04-2011, 12:13 PM
  2. [Selling] password cracker [autoit] [code] [tested on private servers only]
    By b3vad in forum World of Warcraft Buy Sell Trade
    Replies: 4
    Last Post: 12-16-2010, 06:12 AM
  3. [Help] Need someone to test a lua code
    By dude891 in forum World of Warcraft Emulator Servers
    Replies: 3
    Last Post: 04-12-2008, 09:59 PM
  4. [lua help] I need you guys to see if i missed somthing in the code please
    By runiker in forum World of Warcraft Emulator Servers
    Replies: 5
    Last Post: 03-09-2008, 08:19 AM
  5. question->lua mob code.
    By secretdragon008 in forum World of Warcraft Emulator Servers
    Replies: 6
    Last Post: 02-13-2008, 03:13 PM
All times are GMT -5. The time now is 12:03 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search