Always snap to grid

Legacy:ArrayIndexer

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search

About[edit]

ArrayIndexer is a WOTgreal macro that updates indexes of selected defaultproperties array items. It's handy when you reorder array items and dont want to upddate the index numbers manually.

Before[edit]

defaultproperties
{
    DeathSounds(0)=Sound'NewDeath.fn_death01'
    DeathSounds(3)=Sound'NewDeath.fn_death04'
    DeathSounds(4)=Sound'NewDeath.fn_death05'
    DeathSounds(1)=Sound'NewDeath.fn_death02'
    DeathSounds(2)=Sound'NewDeath.fn_death03'
}

After[edit]

defaultproperties
{
    DeathSounds(0)=Sound'NewDeath.fn_death01'
    DeathSounds(1)=Sound'NewDeath.fn_death04'
    DeathSounds(2)=Sound'NewDeath.fn_death05'
    DeathSounds(3)=Sound'NewDeath.fn_death02'
    DeathSounds(4)=Sound'NewDeath.fn_death03'
}

Code[edit]

program ArrayIndexer
begin
    // ========================================================================
    //  UnrealScript ArrayIndexer
    //
    //  Copyright 2005 Roman Switch` Dzieciol, neai o2.pl
    //  http://wiki.beyondunreal.com/wiki/Switch
    // ========================================================================
 
    cpos := 0;
 
    // ========================================================================
 
 
    BlockBeginX, BlockBeginY := BlockBegin();
    BlockEndX, BlockEndY := BlockEnd();
 
    for line:=BlockBeginY to BlockEndY step 1 do
    begin
        SetCursorXY(0,line);
        sline := CurrentLine();
 
        lpos := Pos('(',sline);
        if (lpos <> 0) then
        begin
            sleft := Copy(sline,0,lpos);
        	rpos := Pos(')',sline);
	        if (rpos <> 0) then
	        begin
            	sright := Copy(sline,rpos,Length(sline)-rpos+1);
            	sline := sleft + IntToStr(cpos) + sright;
            	cpos := cpos + 1;
                SetCurrentLine(sline);
	        end;
        end;
	end;
end;