1-4 Script Resizer

key kOwner;
integer iLinkAmount;
integer iScriptAmount=1;
integer iScriptID=1;
integer iTemp;
integer iTemp2;
integer iListener;
integer iCurrentSize=100;
integer iFlags; // 1 - setup done, 2 - setting up, 4 - resizing, 8 - listening, 16 - added
string sScript;
list lTemp;
list lButtons=["Delete","Reset","Size","Custom","+25","-25","+10","-10","+5","-5","+1","-1"];
vector vTemp;
setFlag(integer flag)
{
    if(!(iFlags & flag))
       iFlags+=flag; 
}
unsetFlag(integer flag)
{
    if(iFlags & flag)
       iFlags-=flag; 
}
doResize(integer percentage)
{
    setFlag(4);
    if(iScriptID==1)
        llMessageLinked(LINK_THIS,12121,(string)percentage,NULL_KEY);
    vTemp=llGetPos();
    ;
    if(!(iTemp2=((iTemp=(llCeil((float)iLinkAmount / (float)iScriptAmount))*iScriptID)) - llCeil((float)iLinkAmount / (float)iScriptAmount)))
        iTemp2=1;
    if(percentage != 0)
    {
        iCurrentSize=percentage+iCurrentSize;
        if(iScriptID==1)
            llOwnerSay("Resizing to: "+(string)iCurrentSize+"% ("+(string)percentage+"%)");
    }
    else
    {
        iCurrentSize=100;
        if(iScriptID==1)
            llOwnerSay("Resetting size.");
    }    
    do
    {
        llSetLinkPrimitiveParams(iTemp,[PRIM_POSITION,(((vector)llList2String(lTemp=llParseString2List(llList2String(llGetObjectDetails(llGetLinkKey(iTemp),[OBJECT_DESC]),0),["#"],[""]),1))/100)*iCurrentSize,PRIM_SIZE,((((vector)llList2String(lTemp,0))/100)*iCurrentSize)]);
    }
    while((iTemp=~-iTemp) != iTemp2);
    if(iTemp2==1)
    {
        llSetScale((((vector)llList2String(llParseString2List(llList2String(llGetObjectDetails(llGetLinkKey(iTemp),[OBJECT_DESC]),0),["#"],[""]),0))/100)*iCurrentSize);
        if(!percentage)
            llOwnerSay("Resize operation finished. Object resized to original scale.");
        else
            llOwnerSay("Resize operation finished. Object resized to "+(string)(iCurrentSize)+"%");
    }
    unsetFlag(4);
}
default
{
    state_entry()
    {
        if((iLinkAmount=llGetObjectPrimCount(llGetKey())) > 1)
        {
            if(llGetLinkNumber() > 1)
            {
                llSetObjectDesc((string)llGetScale()+"#"+(string)llGetLocalPos());
                llMessageLinked(LINK_ROOT,45454,"",NULL_KEY);
                llRemoveInventory(llGetScriptName());
            }
            else
            {
                llMessageLinked(LINK_THIS,34343,"",NULL_KEY);
                llOwnerSay("Please wait...");
                llSetTimerEvent(2);
                kOwner=llGetOwner();
                sScript=llGetScriptName();
            }
        }
    }
    on_rez(integer foo)
    {
        if(kOwner!=llGetOwner())
            kOwner=llGetOwner();
    }
    changed(integer change)
    {
        if(change & CHANGED_OWNER)
            kOwner=llGetOwner();
        else if(change & CHANGED_LINK)
        {
            if(iScriptID!=1)
                llRemoveInventory(sScript);
            else if(iFlags)
            {
                llOwnerSay("Changed link configuration. Resetting myself.");
                llResetScript();
            }
        }
    }
    touch_start(integer foo)
    {
        if(iScriptID==1)
        {
            if(iFlags & 8)
            {
                llSetTimerEvent(0);
                llListenRemove(iListener);
                unsetFlag(8);
            }
            if(iFlags & 1)
            {
                setFlag(8);
                iListener=llListen(iTemp=llFloor(llFrand(2137483647)+10000000),"",kOwner,"");
                llDialog(kOwner,"Choose:",lButtons,iTemp);
                llSetTimerEvent(10);
            }
        }
    }
    link_message(integer sender, integer num, string str,key id)
    {
        if(num==34343 && iFlags)
        {
            ++iScriptAmount;
            llMessageLinked(LINK_THIS,23232,"",NULL_KEY);
        }
        if(num==12121 && !(iFlags & 4) && iScriptID!=1)
            doResize((integer)str);
        else if(num == 23232 && !(iFlags & 16))
        {
            if((iScriptID=-~iScriptID) >4)
            {
                llOwnerSay("There are already 4 resize scripts in the object. Deleting myself.");
                llMessageLinked(LINK_THIS,78787,"",NULL_KEY);
                llRemoveInventory(sScript);
            }
            else
                llSetTimerEvent(2);
        }
        else if((num==45454) && (iScriptID == 1))
        {
            if(iFlags & 2)
                if((iTemp=-~iTemp)==(iLinkAmount-1))
                {
                    setFlag(1);
                    llOwnerSay("The resizer is set up and ready to use. The current object will take approximately "+(string)(iLinkAmount*0.2)+" seconds to resize.");
                    llOwnerSay("Add more copies of this script to the object to speed up the operation. Touch the object to get a menu.");
                }
        }
        else if(num==67676)
            llRemoveInventory(sScript);
        else if(num==78787)
            iScriptAmount=~-iScriptAmount;
    }
    listen(integer channel,string name, key id, string message)
    {
        if(iFlags & 8)
        {
            if(iTemp==1)
            {
                llSetTimerEvent(0);
                llListenRemove(iListener);
                doResize((integer)message);
            }
            else if((iTemp=llListFindList(lButtons,[message])) != -1)
            {
                llSetTimerEvent(0);
                llListenRemove(iListener);
                if(!iTemp)
                {
                    llOwnerSay("Deleting resizer.");
                    llMessageLinked(LINK_THIS,67676,"",NULL_KEY);
                    llRemoveInventory(sScript);
                }
                else if(iTemp==1)
                    doResize(0);
                else if(iTemp==2)
                    llOwnerSay("Current size is: "+(string)iCurrentSize+"%");
                else if(iTemp==3)
                {
                    llOwnerSay("Say your custom size offset in percent on channel 1.");
                    iListener=llListen(iTemp=1,"",kOwner,"");
                }
                else
                    doResize((integer)message);
            }
        }
    }
    timer()
    {
        llSetTimerEvent(0);
        if(!iFlags)
        {

            if(iScriptID == 1)
            {
                setFlag(2);
                setFlag(16);
                llOwnerSay("Spreading temporary scripts in object's prims. Please wait til the process finishes...");
                iTemp=iLinkAmount;
                do
                    llGiveInventory(llGetLinkKey(iTemp),sScript);
                while(iTemp=~-iTemp);
                llSetObjectDesc((string)llGetScale()+"#"+(string)llGetLocalPos());
                llOwnerSay("Scripts spread. Please take this object into inventory, rez or wear it again, and select 'tools -> set all scripts to running in selection'");
            }
            else
            {
                setFlag(16);
                llOwnerSay((string)(iScriptAmount=iScriptID)+" resize scripts inserted. It will take approximately "+(string)((iLinkAmount * 0.2) / iScriptID)+" seconds to resize the object now.");
            }
        }
        else
        {
            llListenRemove(iListener);
            setFlag(1);
            llOwnerSay("Menu timed out.");
        }
    }
}

 

Flash Scratch to SL - Your Scripting Tool

Script ImageNeed to write a LSL script and don't know how to script?  I know I hate trying to get my head around LSLS when I an in a time crunch. So why not give Flash Scratch a try! Its a great tool for learning and scoding your own scripts for Second Life without having to pay someone to do it and without a crash course in LSL

A Huge thanks to John Bennet of ATLAS Institute at University of Colorado and Eric Rosenbaum at MIT for writing Scratch for SL to begin with.

Read more: Flash Scratch to SL - Your Scripting Tool