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 againglobals//if this is true doors will only close on leave if there are no units in their rangepublicboolean CLOSE_ONLY_WHEN_EMPTY =true// These are the standart animations for the doors in your mapprivateconstantstring STANDART_OPEN_ANIMATION ="Death Alternate"privateconstantstring STANDART_STAND_OPEN_ANIMATION ="Stand Alternate"privateconstantstring STANDART_CLOSE_ANIMATION ="Birth"privateconstantstring STANDART_STAND_CLOSE_ANIMATION ="stand"endglobals//Doors will only be triggered when the entering unit matches these conditionsprivatefunction DoorEventConditions takesnothingreturnsbooleanreturnnot(IsUnitType(GetFilterUnit(),UNIT_TYPE_DEAD)orGetUnitTypeId(GetFilterUnit())==0)endfunction//-----------Don't modify anything below this line---------globalsprivateintegerarray doors
privaterealarray range
privateinteger total
privatehashtable h
privateboolexpr filt
privateboolexpr enter
privateinteger i
privategroup g
privatetimer tim
endglobalsprivatefunction FilterFunc takesnothingreturnsbooleanreturnGetDestructableTypeId(GetFilterDestructable())== doors[i]andLoadBoolean(h,GetHandleId(GetFilterDestructable()),1)!=trueandLoadBoolean(h,GetHandleId(GetFilterDestructable()),2)!=trueendfunctionprivatefunction DoorActions takesnothingreturnsnothinglocaldestructable d =LoadDestructableHandle(h,GetHandleId(GetTriggeringTrigger()),0)ifGetTriggerEventId()==EVENT_GAME_ENTER_REGIONandnotLoadBoolean(h,GetHandleId(d),0)thencallKillDestructable(d)callSaveBoolean(h,GetHandleId(d),0,true)callSetDestructableAnimation(d,LoadStr(h,GetDestructableTypeId(d),4))callQueueDestructableAnimation(d,LoadStr(h,GetDestructableTypeId(d),5))elseifGetTriggerEventId()==EVENT_GAME_LEAVE_REGIONandLoadBoolean(h,GetHandleId(d),0)thenifnot CLOSE_ONLY_WHEN_EMPTY thencallDestructableRestoreLife(d,GetDestructableMaxLife(d),true)callSaveBoolean(h,GetHandleId(d),0,false)callSetDestructableAnimation(d,LoadStr(h,GetDestructableTypeId(d),6))callQueueDestructableAnimation(d,LoadStr(h,GetDestructableTypeId(d),7))elsecallGroupClear(g)callGroupEnumUnitsInRect(g,LoadRectHandle(h,GetHandleId(d),3), enter)ifFirstOfGroup(g)==nullthencallDestructableRestoreLife(d,GetDestructableMaxLife(d),true)callSaveBoolean(h,GetHandleId(d),0,false)callSetDestructableAnimation(d,LoadStr(h,GetDestructableTypeId(d),6))callQueueDestructableAnimation(d,LoadStr(h,GetDestructableTypeId(d),7))endifendifendifset d =nullendfunctionprivatefunction RegisterEvents takesnothingreturnsnothinglocaldestructable d =GetEnumDestructable()localtrigger t =CreateTrigger()localregion g =CreateRegion()localreal x =GetDestructableX(d)localreal y =GetDestructableY(d)localrect r =Rect(x-range[i], y-range[i], x+range[i], y+range[i])callRegionAddRect(g,r)callSaveBoolean(h,GetHandleId(d),0,false)callSaveDestructableHandle(h,GetHandleId(t),0,d)callSaveRectHandle(h,GetHandleId(d),3,r)callSaveBoolean(h,GetHandleId(d),1,true)callSaveStr(h,GetDestructableTypeId(d),4,STANDART_OPEN_ANIMATION)callSaveStr(h,GetDestructableTypeId(d),5,STANDART_STAND_OPEN_ANIMATION)callSaveStr(h,GetDestructableTypeId(d),6,STANDART_CLOSE_ANIMATION)callSaveStr(h,GetDestructableTypeId(d),7,STANDART_STAND_CLOSE_ANIMATION)callTriggerRegisterEnterRegion(t,g,enter)callTriggerRegisterLeaveRegion(t,g,enter)callTriggerAddAction(t,function DoorActions)set t =nullset d =nullset r =nullset g =nullendfunctionprivatefunction RescanAll takesnothingreturnsnothingset i =0loopexitwhen i >= total
callEnumDestructablesInRect(bj_mapInitialPlayableArea, filt,function RegisterEvents)set i = i +1endloopendfunctionfunction OpenDoor takesdestructable d,boolean flag returnsnothingcallSaveBoolean(h,GetHandleId(h),0,flag)endfunctionfunction ExcludeDoor takesdestructable d,boolean flag returnsnothingcallSaveBoolean(h,GetHandleId(h),2,flag)endfunctionfunction ChangeDoorTypeAnimations takesinteger id,string openAnimation,string standOpenAnimation,string closeAnimation,string standCloseAnimation returnsnothingcallSaveStr(h,id,4,openAnimation)callSaveStr(h,id,5,standOpenAnimation)callSaveStr(h,id,6,closeAnimation)callSaveStr(h,id,7,standCloseAnimation)endfunctionfunction AddDoorType takesinteger id,real enterRange returnsnothingset doors[total]= id
set range[total]= enterRange
callSaveStr(h,id,4,STANDART_OPEN_ANIMATION)callSaveStr(h,id,5,STANDART_STAND_OPEN_ANIMATION)callSaveStr(h,id,6,STANDART_CLOSE_ANIMATION)callSaveStr(h,id,7,STANDART_STAND_CLOSE_ANIMATION)set total = total +1call RescanAll()endfunctionprivatefunction Init takesnothingreturnsnothingset h =InitHashtable()set total =0set filt =Condition(function FilterFunc)set enter =Condition(function DoorEventConditions)set g =CreateGroup()set tim =CreateTimer()endfunctionprivatefunction CatchNewDoors takesinteger objectid,real x,real y,real face,real scale,integer variation returnsnothingcallTimerStart(tim,0.01,false,function RescanAll)endfunctionprivatefunction CatchNewDoors2 takesinteger objectid,real x,real y,real z,real face,real scale,integer variation returnsnothingcallTimerStart(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 againglobals//if this is true doors will only close on leave if there are no units in their rangepublicboolean CLOSE_ONLY_WHEN_EMPTY =true// These are the standart animations for the doors in your mapprivateconstantstring STANDART_OPEN_ANIMATION ="Death Alternate"privateconstantstring STANDART_STAND_OPEN_ANIMATION ="Stand Alternate"privateconstantstring STANDART_CLOSE_ANIMATION ="Birth"privateconstantstring STANDART_STAND_CLOSE_ANIMATION ="stand"endglobals//Doors will only be triggered when the entering unit matches these conditionsprivatefunction DoorEventConditions takesnothingreturnsbooleanreturnnot(IsUnitType(GetFilterUnit(),UNIT_TYPE_DEAD)orGetUnitTypeId(GetFilterUnit())==0)endfunction//-----------Don't modify anything below this line---------globalsprivateintegerarray doors
privaterealarray range
privateinteger total
privatehashtable h
privateboolexpr filt
privateboolexpr enter
privateinteger i
privategroup g
privatetimer tim
endglobalsprivatefunction FilterFunc takesnothingreturnsbooleanreturnGetDestructableTypeId(GetFilterDestructable())== doors[i]andLoadBoolean(h,GetHandleId(GetFilterDestructable()),1)!=trueandLoadBoolean(h,GetHandleId(GetFilterDestructable()),2)!=trueendfunctionprivatefunction DoorActions takesnothingreturnsnothinglocaldestructable d =LoadDestructableHandle(h,GetHandleId(GetTriggeringTrigger()),0)ifGetTriggerEventId()==EVENT_GAME_ENTER_REGIONandnotLoadBoolean(h,GetHandleId(d),0)thencallKillDestructable(d)callSaveBoolean(h,GetHandleId(d),0,true)callSetDestructableAnimation(d,LoadStr(h,GetDestructableTypeId(d),4))callQueueDestructableAnimation(d,LoadStr(h,GetDestructableTypeId(d),5))elseifGetTriggerEventId()==EVENT_GAME_LEAVE_REGIONandLoadBoolean(h,GetHandleId(d),0)thenifnot CLOSE_ONLY_WHEN_EMPTY thencallDestructableRestoreLife(d,GetDestructableMaxLife(d),true)callSaveBoolean(h,GetHandleId(d),0,false)callSetDestructableAnimation(d,LoadStr(h,GetDestructableTypeId(d),6))callQueueDestructableAnimation(d,LoadStr(h,GetDestructableTypeId(d),7))elsecallGroupClear(g)callGroupEnumUnitsInRect(g,LoadRectHandle(h,GetHandleId(d),3), enter)ifFirstOfGroup(g)==nullthencallDestructableRestoreLife(d,GetDestructableMaxLife(d),true)callSaveBoolean(h,GetHandleId(d),0,false)callSetDestructableAnimation(d,LoadStr(h,GetDestructableTypeId(d),6))callQueueDestructableAnimation(d,LoadStr(h,GetDestructableTypeId(d),7))endifendifendifset d =nullendfunctionprivatefunction RegisterEvents takesnothingreturnsnothinglocaldestructable d =GetEnumDestructable()localtrigger t =CreateTrigger()localregion g =CreateRegion()localreal x =GetDestructableX(d)localreal y =GetDestructableY(d)localrect r =Rect(x - range[i], y - range[i], x + range[i], y + range[i])callRegionAddRect(g, r)callSaveBoolean(h,GetHandleId(d),0,false)callSaveDestructableHandle(h,GetHandleId(t),0, d)callSaveRectHandle(h,GetHandleId(d),3, r)callSaveBoolean(h,GetHandleId(d),1,true)callSaveStr(h,GetDestructableTypeId(d),4, STANDART_OPEN_ANIMATION)callSaveStr(h,GetDestructableTypeId(d),5, STANDART_STAND_OPEN_ANIMATION)callSaveStr(h,GetDestructableTypeId(d),6, STANDART_CLOSE_ANIMATION)callSaveStr(h,GetDestructableTypeId(d),7, STANDART_STAND_CLOSE_ANIMATION)callTriggerRegisterEnterRegion(t, g, enter)callTriggerRegisterLeaveRegion(t, g, enter)callTriggerAddAction(t,function DoorActions)set t =nullset d =nullset r =nullset g =nullendfunctionprivatefunction RescanAll takesnothingreturnsnothingset i =0loopexitwhen i >= total
callEnumDestructablesInRect(bj_mapInitialPlayableArea, filt,function RegisterEvents)set i = i +1endloopendfunctionfunction OpenDoor takesdestructable d,boolean flag returnsnothingcallSaveBoolean(h,GetHandleId(h),0, flag)endfunctionfunction ExcludeDoor takesdestructable d,boolean flag returnsnothingcallSaveBoolean(h,GetHandleId(h),2, flag)endfunctionfunction ChangeDoorTypeAnimations takesinteger id,string openAnimation,string standOpenAnimation,string closeAnimation,string standCloseAnimation returnsnothingcallSaveStr(h, id,4, openAnimation)callSaveStr(h, id,5, standOpenAnimation)callSaveStr(h, id,6, closeAnimation)callSaveStr(h, id,7, standCloseAnimation)endfunctionfunction AddDoorType takesinteger id,real enterRange returnsnothingset doors[total]= id
set range[total]= enterRange
callSaveStr(h, id,4, STANDART_OPEN_ANIMATION)callSaveStr(h, id,5, STANDART_STAND_OPEN_ANIMATION)callSaveStr(h, id,6, STANDART_CLOSE_ANIMATION)callSaveStr(h, id,7, STANDART_STAND_CLOSE_ANIMATION)set total = total +1call RescanAll()endfunctionprivatefunction Init takesnothingreturnsnothingset h =InitHashtable()set total =0set filt =Condition(function FilterFunc)set enter =Condition(function DoorEventConditions)set g =CreateGroup()set tim =CreateTimer()endfunctionprivatefunction CatchNewDoors takesinteger objectid,real x,real y,real face,real scale,integer variation returnsnothingcallTimerStart(tim,0.01,false,function RescanAll)endfunctionprivatefunction CatchNewDoors2 takesinteger objectid,real x,real y,real z,real face,real scale,integer variation returnsnothingcallTimerStart(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.
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.