[Log in / Register]
| News | Chat | Pastebin | Donations | Tutorials | Rules | Forums |
| Maps | Skins | Icons | Models | Spells | Tools | Jass | Packs | Hosted Projects | Starcraft II Modding | Starcraft II Resources | Galaxy Wiki |
(Keeps Hive Alive)
Go Back   The Hive Workshop > Tools


Reply
 
Thread Tools
The Hive Workshop Tools:
Script Language Aligner (Jass, vJass, Zinc)
Tool
Highslide JS
Details
Uploaded:13:46, 2nd Jan 2011
Last Updated:07:22, 18th Oct 2012
Keywords:script, code, language, vJass, jass, zinc, delphi, help, structure, align, warcraft, indent
Operating System:Windows XP, Windows Vista, Windows 2000, Windows ME
Category:World Editor Addons & Tools, JASS / Triggers, Misc, Other Useful
Website:

@ first: This resource IS mine! I coded it and everything inside is made by me, The_Witcher!

Script Language Aligner

Have you ever hade a code with a bad indenting??
Moderators always complain about your lack of white space??
it's very difficult to look through a code that looks bad and it's very difficult to review one too!

Simply press the customizable hotkey and all code in the active window gets indented perfectly!
Of course you can always retrieve the original unindented code!

example:
Can you easily read this code?
Jass:
library DoorSystem initializer Init
    // Door system by The_Witcher
    //
// this system opens every instance of the registered doortypes when a units comes close
// if the unit moves away from the door it will close again

    globals
        //if this is true doors will only close on leave if there are no units in their range
        public boolean CLOSE_ONLY_WHEN_EMPTY = true
         // These are the standart animations for the doors in your map
        private constant string STANDART_OPEN_ANIMATION = "Death Alternate"
                private constant string STANDART_STAND_OPEN_ANIMATION = "Stand Alternate"
        private constant string STANDART_CLOSE_ANIMATION = "Birth"
            private constant string STANDART_STAND_CLOSE_ANIMATION = "stand"
    endglobals

    //Doors will only be triggered when the entering unit matches these conditions
            private function DoorEventConditions takes nothing returns boolean
        return not (IsUnitType(GetFilterUnit(),UNIT_TYPE_DEAD) or GetUnitTypeId(GetFilterUnit()) == 0 )
            endfunction

    //-----------Don't modify anything below this line---------

            globals
                private integer array doors
        private real array range
               private integer total
        private hashtable h
                private boolexpr filt
                    private boolexpr enter
        private integer i
        private group g
        private timer tim
    endglobals

            private function FilterFunc takes nothing returns boolean
        return GetDestructableTypeId(GetFilterDestructable()) == doors[i] and LoadBoolean(h,GetHandleId(GetFilterDestructable()),1) != true and LoadBoolean(h,GetHandleId(GetFilterDestructable()),2) != true
    endfunction
        
    private function DoorActions takes nothing returns nothing
                    local destructable d = LoadDestructableHandle(h,GetHandleId(GetTriggeringTrigger()),0)  
        if GetTriggerEventId()==EVENT_GAME_ENTER_REGION and not LoadBoolean(h,GetHandleId(d),0) then
    call KillDestructable(d)
call SaveBoolean(h,GetHandleId(d),0,true)
            call SetDestructableAnimation(d,LoadStr(h,GetDestructableTypeId(d),4))
    call QueueDestructableAnimation(d,LoadStr(h,GetDestructableTypeId(d),5))
        elseif GetTriggerEventId()==EVENT_GAME_LEAVE_REGION and LoadBoolean(h,GetHandleId(d),0) then
            if not CLOSE_ONLY_WHEN_EMPTY then
                call DestructableRestoreLife(d,GetDestructableMaxLife(d),true)
                call SaveBoolean(h,GetHandleId(d),0,false)
      call SetDestructableAnimation(d, LoadStr(h,GetDestructableTypeId(d),6))
                call QueueDestructableAnimation(d, LoadStr(h,GetDestructableTypeId(d),7))
            else
          call GroupClear(g)
                call GroupEnumUnitsInRect(g, LoadRectHandle(h,GetHandleId(d),3), enter)
                if FirstOfGroup(g) == null then
        call DestructableRestoreLife(d,GetDestructableMaxLife(d),true)
                    call SaveBoolean(h,GetHandleId(d),0,false)
               call SetDestructableAnimation(d, LoadStr(h,GetDestructableTypeId(d),6))
             call QueueDestructableAnimation(d, LoadStr(h,GetDestructableTypeId(d),7))
                endif
            endif
endif
set d = null
    endfunction

private function RegisterEvents takes nothing returns nothing
local destructable d = GetEnumDestructable()
local trigger t = CreateTrigger()
local region g = CreateRegion()
local real x = GetDestructableX(d)
local real y = GetDestructableY(d)
local rect r = Rect(x-range[i], y-range[i], x+range[i], y+range[i])
call RegionAddRect(g,r)
call SaveBoolean(h,GetHandleId(d),0,false)
call SaveDestructableHandle(h,GetHandleId(t),0,d)
call SaveRectHandle(h,GetHandleId(d),3,r)
call SaveBoolean(h,GetHandleId(d),1,true)
call SaveStr(h,GetDestructableTypeId(d),4,STANDART_OPEN_ANIMATION)
call SaveStr(h,GetDestructableTypeId(d),5,STANDART_STAND_OPEN_ANIMATION)
call SaveStr(h,GetDestructableTypeId(d),6,STANDART_CLOSE_ANIMATION)
call SaveStr(h,GetDestructableTypeId(d),7,STANDART_STAND_CLOSE_ANIMATION)
call TriggerRegisterEnterRegion(t,g,enter)
call TriggerRegisterLeaveRegion(t,g,enter)
call TriggerAddAction(t,function DoorActions)
set t = null
set d = null
set r = null
set g = null
endfunction

            private function RescanAll takes nothing returns nothing
        set i = 0
        loop
    exitwhen i >= total
       call EnumDestructablesInRect(bj_mapInitialPlayableArea, filt, function RegisterEvents)
     set i = i + 1
        endloop
    endfunction

function OpenDoor takes destructable d, boolean flag returns nothing
call SaveBoolean(h,GetHandleId(h),0,flag)
endfunction

function ExcludeDoor takes destructable d, boolean flag returns nothing
call SaveBoolean(h,GetHandleId(h),2,flag)
endfunction
    
        function ChangeDoorTypeAnimations takes integer id, string openAnimation, string standOpenAnimation, string closeAnimation, string standCloseAnimation returns nothing
      call SaveStr(h,id,4,openAnimation)
        call SaveStr(h,id,5,standOpenAnimation)
    call SaveStr(h,id,6,closeAnimation)
        call SaveStr(h,id,7,standCloseAnimation)
    endfunction

        function AddDoorType takes integer id, real enterRange returns nothing
            set doors[total] = id
        set range[total] = enterRange
                    call SaveStr(h,id,4,STANDART_OPEN_ANIMATION)
        call SaveStr(h,id,5,STANDART_STAND_OPEN_ANIMATION)
            call SaveStr(h,id,6,STANDART_CLOSE_ANIMATION)
                call SaveStr(h,id,7,STANDART_STAND_CLOSE_ANIMATION)
            set total = total + 1
        call RescanAll()
        endfunction

  private function Init takes nothing returns nothing
                set h = InitHashtable()
        set total = 0
                set filt = Condition(function FilterFunc)
            set enter = Condition(function DoorEventConditions)
        set g = CreateGroup()
        set tim = CreateTimer()
        endfunction
        
            private function CatchNewDoors takes integer objectid, real x, real y, real face, real scale, integer variation returns nothing
                call TimerStart(tim,0.01,false,function RescanAll)
            endfunction
    
            private function CatchNewDoors2 takes integer objectid, real x, real y, real z, real face, real scale, integer variation returns nothing
                call TimerStart(tim,0.01,false,function RescanAll)
        endfunction
    
hook CreateDestructable CatchNewDoors
  hook CreateDestructableZ CatchNewDoors2

    endlibrary


Now i use my tool and this is what comes out (all options enabled):

Looks beautiful
Jass:
library DoorSystem initializer Init
    // Door system by The_Witcher
    //
// this system opens every instance of the registered doortypes when a units comes close
// if the unit moves away from the door it will close again

    globals
        //if this is true doors will only close on leave if there are no units in their range
        public boolean CLOSE_ONLY_WHEN_EMPTY = true
         // These are the standart animations for the doors in your map
        private constant string STANDART_OPEN_ANIMATION = "Death Alternate"
        private constant string STANDART_STAND_OPEN_ANIMATION = "Stand Alternate"
        private constant string STANDART_CLOSE_ANIMATION = "Birth"
        private constant string STANDART_STAND_CLOSE_ANIMATION = "stand"
    endglobals

    //Doors will only be triggered when the entering unit matches these conditions
    private function DoorEventConditions takes nothing returns boolean
        return not (IsUnitType(GetFilterUnit(), UNIT_TYPE_DEAD) or GetUnitTypeId(GetFilterUnit()) == 0 )
    endfunction

    //-----------Don't modify anything below this line---------

    globals
        private integer array doors
        private real array range
        private integer total
        private hashtable h
        private boolexpr filt
        private boolexpr enter
        private integer i
        private group g
        private timer tim
    endglobals

    private function FilterFunc takes nothing returns boolean
        return GetDestructableTypeId(GetFilterDestructable()) == doors[i] and LoadBoolean(h, GetHandleId(GetFilterDestructable()), 1) != true and LoadBoolean(h, GetHandleId(GetFilterDestructable()), 2) != true
    endfunction
        
    private function DoorActions takes nothing returns nothing
        local destructable d = LoadDestructableHandle(h, GetHandleId(GetTriggeringTrigger()), 0)
        if GetTriggerEventId() == EVENT_GAME_ENTER_REGION and not LoadBoolean(h, GetHandleId(d), 0) then
            call KillDestructable(d)
            call SaveBoolean(h, GetHandleId(d), 0, true)
            call SetDestructableAnimation(d, LoadStr(h, GetDestructableTypeId(d), 4))
            call QueueDestructableAnimation(d, LoadStr(h, GetDestructableTypeId(d), 5))
        elseif GetTriggerEventId() == EVENT_GAME_LEAVE_REGION and LoadBoolean(h, GetHandleId(d), 0) then
            if not CLOSE_ONLY_WHEN_EMPTY then
                call DestructableRestoreLife(d, GetDestructableMaxLife(d), true)
                call SaveBoolean(h, GetHandleId(d), 0, false)
                call SetDestructableAnimation(d, LoadStr(h, GetDestructableTypeId(d), 6))
                call QueueDestructableAnimation(d, LoadStr(h, GetDestructableTypeId(d), 7))
            else
                call GroupClear(g)
                call GroupEnumUnitsInRect(g, LoadRectHandle(h, GetHandleId(d), 3), enter)
                if FirstOfGroup(g) == null then
                    call DestructableRestoreLife(d, GetDestructableMaxLife(d), true)
                    call SaveBoolean(h, GetHandleId(d), 0, false)
                    call SetDestructableAnimation(d, LoadStr(h, GetDestructableTypeId(d), 6))
                    call QueueDestructableAnimation(d, LoadStr(h, GetDestructableTypeId(d), 7))
                endif
            endif
        endif
        set d = null
    endfunction

    private function RegisterEvents takes nothing returns nothing
        local destructable d = GetEnumDestructable()
        local trigger t = CreateTrigger()
        local region g = CreateRegion()
        local real x = GetDestructableX(d)
        local real y = GetDestructableY(d)
        local rect r = Rect(x - range[i], y - range[i], x + range[i], y + range[i])
        call RegionAddRect(g, r)
        call SaveBoolean(h, GetHandleId(d), 0, false)
        call SaveDestructableHandle(h, GetHandleId(t), 0, d)
        call SaveRectHandle(h, GetHandleId(d), 3, r)
        call SaveBoolean(h, GetHandleId(d), 1, true)
        call SaveStr(h, GetDestructableTypeId(d), 4, STANDART_OPEN_ANIMATION)
        call SaveStr(h, GetDestructableTypeId(d), 5, STANDART_STAND_OPEN_ANIMATION)
        call SaveStr(h, GetDestructableTypeId(d), 6, STANDART_CLOSE_ANIMATION)
        call SaveStr(h, GetDestructableTypeId(d), 7, STANDART_STAND_CLOSE_ANIMATION)
        call TriggerRegisterEnterRegion(t, g, enter)
        call TriggerRegisterLeaveRegion(t, g, enter)
        call TriggerAddAction(t, function DoorActions)
        set t = null
        set d = null
        set r = null
        set g = null
    endfunction

    private function RescanAll takes nothing returns nothing
        set i = 0
        loop
            exitwhen i >= total
            call EnumDestructablesInRect(bj_mapInitialPlayableArea, filt, function RegisterEvents)
            set i = i + 1
        endloop
    endfunction

    function OpenDoor takes destructable d, boolean flag returns nothing
        call SaveBoolean(h, GetHandleId(h), 0, flag)
    endfunction

    function ExcludeDoor takes destructable d, boolean flag returns nothing
        call SaveBoolean(h, GetHandleId(h), 2, flag)
    endfunction
    
    function ChangeDoorTypeAnimations takes integer id, string openAnimation, string standOpenAnimation, string closeAnimation, string standCloseAnimation returns nothing
        call SaveStr(h, id, 4, openAnimation)
        call SaveStr(h, id, 5, standOpenAnimation)
        call SaveStr(h, id, 6, closeAnimation)
        call SaveStr(h, id, 7, standCloseAnimation)
    endfunction

    function AddDoorType takes integer id, real enterRange returns nothing
        set doors[total] = id
        set range[total] = enterRange
        call SaveStr(h, id, 4, STANDART_OPEN_ANIMATION)
        call SaveStr(h, id, 5, STANDART_STAND_OPEN_ANIMATION)
        call SaveStr(h, id, 6, STANDART_CLOSE_ANIMATION)
        call SaveStr(h, id, 7, STANDART_STAND_CLOSE_ANIMATION)
        set total = total + 1
        call RescanAll()
    endfunction

    private function Init takes nothing returns nothing
        set h = InitHashtable()
        set total = 0
        set filt = Condition(function FilterFunc)
        set enter = Condition(function DoorEventConditions)
        set g = CreateGroup()
        set tim = CreateTimer()
    endfunction
        
    private function CatchNewDoors takes integer objectid, real x, real y, real face, real scale, integer variation returns nothing
        call TimerStart(tim, 0.01, false, function RescanAll)
    endfunction
    
    private function CatchNewDoors2 takes integer objectid, real x, real y, real z, real face, real scale, integer variation returns nothing
        call TimerStart(tim, 0.01, false, function RescanAll)
    endfunction
    
    hook CreateDestructable CatchNewDoors
    hook CreateDestructableZ CatchNewDoors2

endlibrary


//Code indented using The_Witcher's Script language Aligner
//Download the newest version and report bugs at www.hiveworkshop.com


NOTE: works for the languages Jass, vJass and Zinc.

Updates
v.1.1: added support for static ifs, changed UI
v.1.2: major code changes, removed pascal support (since it has its own aligner), support for constant functions and crap code without spaces like ' if(s==2)then'
v.1.3: added support for modules
v.2.0: rewrote the whole code: no more bugs regardin static, private, constant etc. prefixes, option to recover old code (in case the program fails), option to format spaces
v.2.1: added support for strings like "-n" which became " - n" before, added support for /* and */, fixed a bug regarding the "private" and "static" combination, changed default options
v.3.0: rewrote a lot of the code! added zinc support and fixed "operator x=" bug
v.3.1: fixed a small bug, fixed interface bug, fixed "i = - 1" bug so it becomes "i = -1" now
v.3.2: added hotkey ctrl + [yourHotkey] to automatically indent
Rating - 4.43 (7 votes)
(Hover and click)
Moderator Comments
Recommended
18:51 October 1, 2012:
Magtheridon96:

Approved.
4/5 for being a life-saver when I find someone with terrible code indentation.

This tool is approved and works properly.


Download Script Language Aligner.exe
(1019 KB, 762 Downloads)

Old 01-02-2011, 01:55 PM   #2 (permalink)
Registered User The_Witcher
#1 in Top 20 Spells!
 
The_Witcher's Avatar
 
Join Date: Dec 2008
Posts: 269
The_Witcher is just really nice (295)The_Witcher is just really nice (295)The_Witcher is just really nice (295)The_Witcher is just really nice (295)The_Witcher is just really nice (295)
Please tell me what you think about it and report bugs etc. to me by PM!

tool supports english and german language (automatic detection)
__________________
Need a well coded Spell or System?? PM me! My Resources
The_Witcher is offline   Reply With Quote
Old 01-02-2011, 02:04 PM   #3 (permalink)
Registered User Adiktuz
BusyWithSchool
 
Adiktuz's Avatar
 
Join Date: Oct 2008
Posts: 8,502
Adiktuz has much of which to be proud (1083)Adiktuz has much of which to be proud (1083)Adiktuz has much of which to be proud (1083)Adiktuz has much of which to be proud (1083)Adiktuz has much of which to be proud (1083)
oh, pretty cool... especially for those who are lazy to properly indent their codes. ^_^

I'll be using this for some codes on my map which has bad aligning. ^_^
Adiktuz is online now   Reply With Quote
Old 01-02-2011, 02:26 PM   #4 (permalink)
Registered User hell gate
i guess im back?
 
hell gate's Avatar
 
Join Date: Nov 2008
Posts: 611
hell gate will become famous soon enough (119)hell gate will become famous soon enough (119)hell gate will become famous soon enough (119)
hehe nice :)
made with visual studio?
__________________
hell gate is offline   Reply With Quote
Old 01-13-2011, 03:23 AM   #5 (permalink)
Registered User Cokemonkey11
\m/
 
Cokemonkey11's Avatar
 
Join Date: May 2006
Posts: 1,985
Cokemonkey11 is just really nice (338)Cokemonkey11 is just really nice (338)Cokemonkey11 is just really nice (338)
Very awesome, will help with reading other's code.

5*
Cokemonkey11 is online now   Reply With Quote
Old 01-13-2011, 11:15 AM   #6 (permalink)
Registered User Kercyn
foo bar
 
Kercyn's Avatar
 
Join Date: Feb 2009
Posts: 854
Kercyn has a spectacular aura about (124)Kercyn has a spectacular aura about (124)Kercyn has a spectacular aura about (124)Kercyn has a spectacular aura about (124)
A handy tool. Could really help those too lazy to indent their their code, as Adictuz said :)
__________________
Kercyn is offline   Reply With Quote
Old 01-13-2011, 11:11 PM   #7 (permalink)
Forum Moderator PurgeandFire
ʕ•͡ᴥ•ʔ
 
PurgeandFire's Avatar
Resource & Tutorial Moderator
 
Join Date: Nov 2006
Posts: 3,528
PurgeandFire has much of which to be proud (1095)PurgeandFire has much of which to be proud (1095)PurgeandFire has much of which to be proud (1095)PurgeandFire has much of which to be proud (1095)PurgeandFire has much of which to be proud (1095)
Great tool. :) I believe Bob666 made something similar (as well as JASSCraft), but I don't think it works with vJass so this tool is definitely good. It works fine without any bugs as far as I've checked.
PurgeandFire is offline   Reply With Quote
Old 01-14-2011, 10:45 AM   #8 (permalink)
Registered User Miss_Foxy
Don't Mess With The Fox
 
Miss_Foxy's Avatar
 
Join Date: Oct 2008
Posts: 2,824
Miss_Foxy is just really nice (318)Miss_Foxy is just really nice (318)
This is nice, simple and sweet.
__________________
Don't Mess With Me . . .
Blizzard Is Just Awesome.
. . . Or Else
Miss_Foxy is offline   Reply With Quote
Old 01-20-2011, 07:18 PM   #9 (permalink)
Registered User Raven0
a.k.a. Spectre
 
Raven0's Avatar
 
Join Date: Oct 2010
Posts: 907
Raven0 is just really nice (324)Raven0 is just really nice (324)
Terraining Contest #10 - Winner: Enter the Dream PayPal Donor: This user has donated at least $20 to The Hive. 
epic ^-^
Raven0 is offline   Reply With Quote
Old 01-21-2011, 03:20 PM   #10 (permalink)
Registered User Teldrassil
User
 
Teldrassil's Avatar
 
Join Date: Feb 2005
Posts: 425
Teldrassil has little to show at this moment (40)Teldrassil has little to show at this moment (40)Teldrassil has little to show at this moment (40)Teldrassil has little to show at this moment (40)Teldrassil has little to show at this moment (40)
Very nice and useful, glad to see you're still making such great stuff Witcher :)

I'm all for coding convenience.
Teldrassil is offline   Reply With Quote
Old 01-21-2011, 11:23 PM   #11 (permalink)
Registered User naitsirk
Currently learning JASS
 
naitsirk's Avatar
 
Join Date: Jan 2009
Posts: 601
naitsirk has little to show at this moment (57)
What language is it scripted in, and could I get the code to look at it and learn it? (If it's C# or C++, or JAVA)
__________________
Welcome.... To the world of Artor'Kisa : The Prologe

Hehe, This box is for.... never mind:)
naitsirk is offline   Reply With Quote
Old 01-22-2011, 06:23 PM   #12 (permalink)
Registered User CeDiL
Bear ™
 
CeDiL's Avatar
 
Join Date: Jan 2008
Posts: 355
CeDiL has disabled reputation
Indeed as said, this is great. Good job.
CeDiL is offline   Reply With Quote
Old 01-26-2011, 07:59 PM   #13 (permalink)
Registered User Sorceress
❄~ʕ•ᴥ•ʔ~❄
 
Sorceress's Avatar
 
Join Date: Jul 2009
Posts: 1,156
Sorceress has disabled reputation
Super Donor: This user has donated at least $100 to The Hive. 
▄██████████████▄▐█▄▄▄▄█▌
██████▌▄▌▄▐▐▌███▌▀▀██▀▀
████▄█▌▄▌▄▐▐▌▀███▄▄█▌
▄▄▄▄▄██████████████▀

Noooo, jkjk.
Could be Very useful for alot of people.
Nice one!
__________________
Sorceress is offline   Reply With Quote
Old 01-27-2011, 12:25 AM   #14 (permalink)
Registered User Garfield1337
Editing worlds
 
Garfield1337's Avatar
 
Join Date: Jul 2009
Posts: 1,663
Garfield1337 is a glorious beacon of light (449)Garfield1337 is a glorious beacon of light (449)Garfield1337 is a glorious beacon of light (449)Garfield1337 is a glorious beacon of light (449)Garfield1337 is a glorious beacon of light (449)Garfield1337 is a glorious beacon of light (449)
This is surely useful,not only if you're lazy,but you can write code faster without indenting and use this tool to align it :3
__________________
Banjoball - My lolzy football map
Garfield1337 is offline   Reply With Quote
Old 01-30-2011, 08:18 AM   #15 (permalink)
Registered User DoctorGester
Cube
 
DoctorGester's Avatar
 
Join Date: Dec 2009
Posts: 43
DoctorGester has little to show at this moment (6)
Very useful.
DoctorGester is offline   Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 09:18 AM.





Powered by vBulletin
Copyright 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.5.1 PL2
Copyright © Ralle