Perfect Resize 1 script

Thread Started By steadymobbin

2482
0
  • 31 Vote(s) - 2.97 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rate Thread
#1
PHP Code:
vector vSize;
vector vPos1;
vector vPos;
string sPctP3 "5";
string sPctP2 "2";
string sPctP1 "1";
string sPctM3 "5";
string sPctM2 "2";
string sPctM1 "1";
string sPct;
list 
lSortPrims;
list 
lSizes;
list 
lPos;
list 
lName;
list 
lElem;
integer iSens;
integer iNumberOfPrims;
integer iNoMoreMax;
integer iNbPasses;
integer iMenuOn;
integer iLast;
integer iIdx;
integer iHugeUsed;
integer iFirst;
integer iFin;
integer iError;
integer iEcouteMenu;
integer iDeb;
integer iCurrentMenu;
integer iCanalMenu;
integer iCanalComm = -8547548;
integer iBcl;
integer iAllowResizeHugePrims = -1;
float fTmp;
float fMin;
float fMax;
float fLimiteMax;
float fFactor;
float fDefault;
integer TestError()
{
    if( 
fMax fLimiteMax )
        
ControlSizePosvSizevPos );

    return( 
iError );
}
float MinMaxValinteger iOperation )
{
    return( 
llListStatisticsiOperation, [ vSize.xvSize.yvSize.] ) );
}



GoBackToGoodSize()
{
    
llOwnerSay"Error, back to previous good size..." );

    
sPct "aborted";

    if( 
llRoundfFactor 100.0 ) == 101 )
        
iNoMoreMax TRUE;

    
fMin     /= fFactor;
    
fMax     /= fFactor;
    
iFin      iDeb iSens;
    
iDeb      iIdx;
    
iSens    *= -1;
    
fFactor   1.0;
    
iNbPasses 3;

    if( 
iNoMoreMax )
        
fLimiteMax fMax;

    do
    {
        
Booster();
        
iError FALSE;

        for( 
iIdx iDebiIdx != iFiniIdx += iSens )
        {
            
iBcl llList2IntegerlSortPrimsiIdx );

            
lElem = [ PRIM_SIZEllList2VectorlSizesiIdx ) ];

            if( 
iBcl != iFirst )
            {
                
vPos  llList2VectorlPosiIdx );

                
lElem += [ PRIM_POSITIONvPos ];
            }

            
llSetLinkPrimitiveParamsFastiBcllElem );
            
llSetLinkPrimitiveParamsFastiBcllElem );
            
llSetLinkPrimitiveParamsFastiBcllElem );
        }

        
ControlBuildFALSE );
    }
    while( 
iError && --iNbPasses );

    if( 
iError )
        
llOwnerSay"Sorry, the build is broken and can't be repaired." );
}



GetSizePos()
{
    
vSize llList2VectorllGetLinkPrimitiveParamsiBcl, [ PRIM_SIZE ] ), ) * fFactor;

    if( 
iBcl == iFirst )
    {
        if( 
llGetAttached() )

            
vPos llGetLocalPos();
        else

            
vPos llGetRootPosition();
    }
    else

        
vPos = ( ( llList2VectorllGetLinkPrimitiveParamsiBcl, [ PRIM_POSITION ] ), ) - llGetRootPosition() ) / llGetRootRotation() ) * fFactor;
}



ControlSizePosvector vRefSizevector vRefPos )
{
    if( 
llVecDistllList2VectorllGetLinkPrimitiveParamsiBcl, [ PRIM_SIZE ] ), ), vRefSize ) > 0.001 )
        
iError TRUE;
    else if( 
iBcl != iFirst )
    {
        if( 
llVecDist( ( llList2VectorllGetLinkPrimitiveParamsiBcl, [ PRIM_POSITION ] ), ) - llGetRootPosition() ) / llGetRootRotation(),
                       
vRefPos ) > 0.001 )
        
iError TRUE;
    }
}






ControlBuildinteger iBoost )
{
    if( 
iBoost )
        
Booster();



    for( 
iIdx iDebiIdx != iFiniIdx += iSens )
    {
        
iBcl llList2IntegerlSortPrimsiIdx );

        
ControlSizePosllList2VectorlSizesiIdx ) * fFactorllList2VectorlPosiIdx ) * fFactor );

        if( 
iError )
        {
            if( 
iBoost )
                
iIdx iFin iSens;
            return;
        }
    }
}



ChangeSizePos()
{
    
Booster();

    for( 
iIdx iDebiIdx != iFiniIdx += iSens )
    {
        
iBcl llList2IntegerlSortPrimsiIdx );
        
GetSizePos();

        
llSetLinkPrimitiveParamsFastiBcl, [ PRIM_SIZEvSizePRIM_POSITIONvPos ] );
        
llSetLinkPrimitiveParamsFastiBcl, [ PRIM_POSITIONvPos ] );
        
llSetLinkPrimitiveParamsFastiBcl, [ PRIM_POSITIONvPos ] );

        if( 
TestError() )
            return;
    }
}



ChangeSizeinteger iCorrect )
{
    
Booster();

    for( 
iIdx iDebiIdx != iFiniIdx += iSens )
    {
        
iBcl llList2IntegerlSortPrimsiIdx );
        
GetSizePos();

        if( 
iCorrect )
            
vPos /= fFactor;

        
llSetLinkPrimitiveParamsFastiBcl, [ PRIM_SIZEvSize ] );

        if( 
TestError() )
            return;
    }
}



ChangePosinteger iCorrect )
{
    
Booster();

    for( 
iIdx iDebiIdx != iFiniIdx += iSens )
        if( ( 
iBcl llList2IntegerlSortPrimsiIdx ) ) != iFirst )
        {
            
GetSizePos();
            
vPos1 vPos fFactor;

            if( 
iCorrect )
                
vSize /= fFactor;

            
llSetLinkPrimitiveParamsFastiBcl, [ PRIM_POSITIONvPos ] );
            
llSetLinkPrimitiveParamsFastiBcl, [ PRIM_POSITIONvPos ] );
            
llSetLinkPrimitiveParamsFastiBcl, [ PRIM_POSITIONvPos ] );

            if( 
TestError() )
                return;
        }
}



Booster()
{
    for( 
iBcl 0iBcl 5000iBcl++ );
}


AlreadyAtinteger iMessstring sMess )
{
    if( 
iMess )
    {
        
llOwnerSay"Already at " sMess " size." );
        
Menu();
    }
}






init()
{
    
Booster();

    
iNumberOfPrims llGetNumberOfPrims();
    
iFirst         = (integer)( iNumberOfPrims );
    
iLast          iNumberOfPrims - (integer)( iNumberOfPrims == );

    
llOwnerSay"Searching min/max prim size..." );

    
fMin    10.0;
    
fMax    0.01;
    
fFactor 1.0;
    for( 
iBcl iFirst; ( fMax <= 10.0 || iAllowResizeHugePrims ) && iBcl <= iLastiBcl++ )
    {
        
GetSizePos();

        if( 
iBcl == iFirst )
        {
            
fDefault vSize.x;
            
lElem = [ 0.0iFirst ];
        }
        else
            
lElem += [ llVecDistZERO_VECTORvPos ), iBcl ];

        
fTmp MinMaxValLIST_STAT_MIN );
        if( 
fTmp fMin )
            
fMin fTmp;

        
fTmp MinMaxValLIST_STAT_MAX );
        if( 
fTmp fMax )
            
fMax fTmp;
    }

    if( 
fMax 10.0 && ! iAllowResizeHugePrims )
    {
        
iHugeUsed TRUE;
        
llOwnerSay"Script not active, object uses huge prim." );
    }
    else
    {
        
llOwnerSay"Size range : " + (string)fMin " -> " + (string)fMax );

        
iNoMoreMax FALSE;
        
iHugeUsed  FALSE;

        
llOwnerSay"Sorting prims..." );

        
lElem llListSortlElem2TRUE );

        
lSortPrims = [];
        for( 
iBcl 1iBcl llGetListLengthlElem ); iBcl += )
            
lSortPrims += [ llList2IntegerlElemiBcl ) ];

        
llOwnerSay( (string)iNumberOfPrims " prim" llList2String( [ """s" ], (integer)(iNumberOfPrims 1) ) + " sorted." );

        
fLimiteMax llListStatisticsLIST_STAT_MAX, [ 10.0fMax ] );

        
llOwnerSay"Storing size/pos of each prim..." );

        
SaveSizePos();
    }

    
llOwnerSay"Init. complete." );
}



SaveSizePos()
{
    
Booster();

    
fFactor 1.0;
    
lSizes  = [];
    
lPos    = [];

    for( 
iIdx 0iIdx != iNumberOfPrimsiIdx++ )
    {
        
iBcl llList2IntegerlSortPrimsiIdx );
        
GetSizePos();

        
lSizes += [ vSize ];
        
lPos   += [ vPos  ];
    }
}



Resizeinteger iMess )
{

    
fMin *= fFactor;
    
fMax *= fFactor;

    
sPct "done";

    if( 
fFactor 1.0 )
    {

        
iDeb  llGetListLengthlSortPrims ) - 1;
        
iFin  = -1;
        
iSens = -1;
    }
    else
    {

        
iDeb  0;
        
iFin  llGetListLengthlSortPrims );
        
iSens 1;
    }

    
iError FALSE;

    if( 
fFactor 0.5 )

        
ChangePosFALSE );
    else if( 
fFactor 2.0 )

        
ChangeSizeFALSE );
    else

        
ChangeSizePos();

    if( ! 
iError )
    {
        if( 
fFactor 0.5 )

            
ChangeSizeTRUE );
        else if( 
fFactor 2.0 )

            
ChangePosTRUE );
    }

    if( ! 
iError )
        
ControlBuildTRUE );

    if( 
iError )

        
GoBackToGoodSize();
    else
    {

        
SaveSizePos();
        if( 
fMax == 10.0 && ! iAllowResizeHugePrims )
        {
            
iNoMoreMax TRUE;
            
fLimiteMax fMax;
        }
    }

    if( 
fMax fLimiteMax )

        
fLimiteMax fMax;


    
llResetTime();

    if( 
iMess )
    {

        
llOwnerSay"Resize " sPct "." );
        
Menu();
    }
}



MinimumSizeinteger iMess )
{
    if( ( 
fFactor 0.01 fMin ) != 1.0 )
    {
        if( 
iMess )
        {
            
sPct = (string)llRound( ( fFactor 1.0 ) * 100.0 );
            if( 
fFactor 1.0 )
                
sPct "+" sPct;
            
llOwnerSay"Minimum size (" sPct "%)..." );
        }

        
ResizeiMess );
    }
    else
        
AlreadyAtiMess"minimum" );
}



Menu()
{
    
llSetTimerEvent30.0 );
    
llDialogllGetOwner(),
              
"Resizer action :\n" +
              
"Quit : Leave this menu.\n" +
              
"Options : Current size becomes default.\n" +
              
">> : Next set of percentages.\n" +
              
"Min : Resize to minimum size.\n" +
              
"Default : Return to initial size.\n" +
              
"Max : Resize to maximum size.",
              [ 
"Quit""Options"">>",
                
"-" sPctM1 "%""Min",     "+" sPctP1 "%",
                
"-" sPctM2 "%""Default""+" sPctP2 "%",
                
"-" sPctM3 "%""Max",     "+" sPctP3 "%" ],
              
iCanalMenu );
}



MaximumSizeinteger iMess )
{
    if( ( 
fFactor fLimiteMax fMax ) != 1.0 )
    {
        if( 
iMess )
        {
            
sPct = (string)llRound( ( fFactor 1.0 ) * 100.0 );
            if( 
fFactor 1.0 )
                
sPct "+" sPct;
            
llOwnerSay"Maximum size (" sPct "%)..." );
        }

        
ResizeiMess );
    }
    else
        
AlreadyAtiMess"maximum" );
}



FinMenuinteger iAlert )
{
    
iMenuOn FALSE;
    
llSetTimerEvent0.0 );
    
llListenRemoveiEcouteMenu );
    if( 
iAlert )
        
llOwnerSay"Menu timeout." );
}



DefaultSizeinteger iMess )
{
    
vSize llList2VectorllGetLinkPrimitiveParamsiFirst, [ PRIM_SIZE ] ), );

    if( ( 
fFactor fDefault vSize.) != 1.0 )
    {
        if( 
iMess )
        {
            
sPct = (string)llRound( ( fFactor 1.0 ) * 100.0 );
            if( 
fFactor 1.0 )
                
sPct "+" sPct;
            
llOwnerSay"Default size (" sPct "%)..." );
        }

        
ResizeiMess );
    }
    else
        
AlreadyAtiMess"default" );
}


default
{
    
state_entry()
    {
        if( 
iAllowResizeHugePrims )
            
iAllowResizeHugePrims = (integer)( llSubStringIndexllGetSimulatorHostname(), ".lindenlab.com" ) < );

        
init();
        
llListeniCanalComm""NULL_KEY"" );
    }

    
changedinteger iChange )
    {
        if(   ( 
iChange CHANGED_LINK  ) ||
            ( ( 
iChange CHANGED_SCALE ) &&
              
llGetTime() > 5.0 llList2Float( [ llGetRegionTimeDilation(), 0.01 ],
                                                (integer)( 
llGetRegionTimeDilation() < 0.01 ) ) ) )
            
init();
    }

    
listeninteger iChannelstring sNamekey kIdstring sMess )
    {
        if( 
iChannel == iCanalMenu )
        {
            
llSetTimerEvent(  0.0 );

            if( 
sMess == ">>" )
            {
                if( (++
iCurrentMenu) == )
                    
iCurrentMenu 0;

                if( ! 
iCurrentMenu )
                {
                    
sPctM1 "1";
                    
sPctM2 "2";
                    
sPctM3 "5";
                    
sPctP1 "1";
                    
sPctP2 "2";
                    
sPctP3 "5";
                }
                else if( 
iCurrentMenu == )
                {
                    
sPctM1 "10";
                    
sPctM2 "25";
                    
sPctM3 "50";
                    
sPctP1 "10";
                    
sPctP2 "25";
                    
sPctP3 "50";
                }
                else
                {
                    
sPctM1 "75";
                    
sPctM2 "85";
                    
sPctM3 "95";
                    
sPctP1 "75";
                    
sPctP2 "100";
                    
sPctP3 "200";
                }

                
Menu();
            }
            else if( 
sMess == "Options" || sMess == " " )
            {
                
llSetTimerEvent30.0 );
                
llDialogllGetOwner(),
                          
"\nResizer options :\n \n" +
                          
"Quit : Leave this menu.\n" +
                          
"BACK : To main menu.\n" +
                          
"Set default : Current size is default.\n" +
                          
"Remove : Remove the script.",
                          [ 
"Quit"" ""BACK",
                            
"Set default"" ""Remove" ],
                          
iCanalMenu );
            }
            else if( 
sMess == "BACK" )
                
Menu();
            else if( 
sMess == "Set default" )
            {
                
vSize llList2VectorllGetLinkPrimitiveParamsiFirst, [ PRIM_SIZE ] ), );
                
fDefault vSize.x;

                if( 
llGetAttached() )
                    
llSayiCanalComm, (string)llGetOwner() + "|Default|" + (string)fDefault );

                
llOwnerSay"This size is now the default size." );
                
Menu();
            }
            else if( 
sMess == "Remove" )
            {
                
llSetTimerEvent30.0 );
                
llDialogllGetOwner(),
                          
"\nSure to remove the script from this object ?",
                          [ 
"Yes""No" ],
                          
iCanalMenu );
            }
            else if( 
sMess == "Default" )
                
DefaultSizeTRUE );
            else if( 
sMess == "Min" )
                
MinimumSizeTRUE );
            else if( 
sMess == "Max" )
                
MaximumSizeTRUE );
            else if( ( 
iBcl llListFindList( [ "+""-" ], [ llGetSubStringsMess0) ] ) ) >= )
            {
                
fFactor 1.0 + (float)llGetSubStringsMess0, -) / 100.0;
                
fTmp    llList2Float( [ llList2Float( [ 10.010000.0 ], iAllowResizeHugePrims ), fLimiteMax ], iNoMoreMax );

                if( 
fMin fFactor 0.01 )
                    
fFactor 0.01 fMin;
                else if( 
fMax fFactor fTmp )
                    
fFactor fTmp fMax;

                if( 
fMin fFactor >= 0.01 && fMax fFactor <= fTmp && llRoundfFactor 100.0 ) != 100 )
                {
                    
sPct = (string)llRound( ( fFactor 1.0 ) * 100.0 ) + "%";
                    if( 
fFactor 1.0 )
                        
sPct "+" sPct;
                    
llOwnerSayllList2String( [ "Increas""Reduc" ], iBcl ) + "ing size : " +
                                
sPct llList2String( [ " (" sMess " asked)""" ], (integer)(sMess == sPct) ) + "..." );

                    if( 
llGetAttached() )
                        
llSayiCanalComm, (string)llGetOwner() + "|Factor|" + (string)fFactor );

                    
ResizeTRUE );
                }
                else
                {
                    
llOwnerSay"Out of size range." );
                    
Menu();
                }
            }
            else
            {
                
FinMenuFALSE );

                if( 
sMess == "Yes" )
                {
                    if( 
llGetAttached() )
                        
llSayiCanalComm, (string)llGetOwner() + "|Remove" );
                    
llRemoveInventoryllGetScriptName() );
                }
            }
        }
        else if( 
llGetAttached() && sName != llGetObjectName() )
        {
            
lElem llParseString2ListsName, [ " " ], [ "" ] );
            if( 
llGetListLengthlElem ) < )
                return;
            
lName llParseString2ListllGetObjectName(), [ " " ], [ "" ] );
            if( 
llGetListLengthlName ) < )
                return;

            if( 
llDumpList2StringllList2ListlElem0, -), " " ) !=
                
llDumpList2StringllList2ListlName0, -), " " ) )
                return;

            
lElem llParseString2ListsMess, [ "|" ], [ "" ] );

            if( 
llList2StringlElem) == (string)llGetOwner() )
            {
                if( 
llList2StringlElem) == "Remove" )
                    
llRemoveInventoryllGetScriptName() );
                else if( 
llList2StringlElem) == "Factor" )
                {
                    
fFactor llList2FloatlElem);
                    
ResizeFALSE );

                    
llResetTime();
                }
                else if( 
llList2StringlElem) == "Min" )
                    
MinimumSizeFALSE );
                else if( 
llList2StringlElem) == "Max" )
                    
MaximumSizeFALSE );
                else if( 
llList2StringlElem) == "Default" )
                {
                    if( 
llGetListLengthlElem ) == )
                        
DefaultSizeFALSE );
                    else
                        
fDefault llList2FloatlElem);
                }
            }
        }
    }

    
timer()
    {
        
FinMenuTRUE );
    }

    
touch_startinteger iNum )
    {
        if( 
llDetectedKey) == llGetOwner() && ! iMenuOn && ! iHugeUsed )
        {

            
iMenuOn TRUE;
            
iCanalMenu iCanalComm 10 - (integer)llFrand124578 );
            
iEcouteMenu llListeniCanalMenu""llGetOwner(), "" );
            
Menu();
        }
    }

[Image: guns-bullet-shirt_recreated.jpg]
Reply




Possibly Related Threads…
Thread Author Replies Views Last Post
  Perfect MailBox steadymobbin 0 2,339 02-18-2013, 02:55 AM
Last Post: steadymobbin

Forum Jump:

1 Guest(s)
Share this:

About Second Life Copybot

Second Life CopyBot Forum is a place where you can get items for Second Life and other vitual worlds for free. With our CopyBot viewers you can export and import any content from these virtual worlds and modify them in 3D software such as Blender, 3D studio Macx etc...