Buddy Builder Base

Written by Kitsune
//////////START MULTI SCRIPT
 
////SCRIPT START ////MAIN
// Builders' Buddy 1.0 (Base Prim)
//
// by Newfie Pendragon, March 2006
//
// This script is distributed with permission that it may be used in
// any way, or may be further modified/included in resale items.
// HOWEVER, if this script is used as part of a for-sale product,
// it is required that appropriate credit be given to Newfie for
// the script (or portions used in derivatives).  That's a fair price
// in exchange for unlimited use of this script, dontcha think?
 
//INSTRUCTIONS
//(These instructions use channel 1234 in the examples, but can be
//  changed further down in the code to whatever channel you wish.)
//
// This is the *Base Prim* half of the Builders' Buddy system.  Drop
// it into the prim that will be the container/box that will be used
// to store the building once completed.  Drop the *Component* scripts
// into each 'piece' of the building.
//
// QUICK USE:
// - Drop this script in the Base.
// - Drop the "Component" Script in each building part.
// - Type: /12345 RECORD
// - Take all building parts into inventory
// - Drag building parts from inventory into Base Prim
// - Type /12345 BUILD
//
// OTHER COMMANDS
// - To reposition, move/rotate Base Prim Type: /12345 MOVE
// - To lock into position (removes scripts) Type: /12345 DONE
// - To delete building pieces: /12345 CLEAN
 
//////////////////////////////////////////////////////////////////////////////////////////
// Configurable Settings
integer CHAN = 12345;        //Channel used to talk to Base Prim; change if you want
integer PRIMCHAN = 12346;    //Channel used by Base Prim to talk to Component Prims;
// This must match in both scripts
 
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
default
{
        //////////////////////////////////////////////////////////////////////////////////////////
        state_entry()
        {
                llListen(CHAN, "", llGetOwner(), "");
        }
 
        //////////////////////////////////////////////////////////////////////////////////////////
        listen(integer iChan, string sName, key kID, string sText)
        {
                //////////////////////////////////////////////////////////////////////////////////////////
                sText = llToUpper(sText);
                if( sText == "RECORD" )
                {
                        llOwnerSay("Recording positions...");
                        llShout(PRIMCHAN, "RECORD " + llDumpList2String([ llGetPos(), llGetRot() ], "|"));
                        return;
                }
 
                //////////////////////////////////////////////////////////////////////////////////////////
                if( sText == "BUILD" )
                {
                        vector vThisPos = llGetPos();
                        rotation rThisRot = llGetRot();
                        integer i;
                        integer iCount = llGetInventoryNumber(INVENTORY_OBJECT);
 
                        //Loop through backwards (safety precaution in case of inventory change)
                        llOwnerSay("Rezzing build pieces...");
                        for( i = iCount - 1; i >= 0; i-- )
                        {
                                llRezObject(llGetInventoryName(INVENTORY_OBJECT, i), vThisPos, ZERO_VECTOR, rThisRot, PRIMCHAN);
                        }
 
                        llOwnerSay("Positioning");
                        llShout(PRIMCHAN, "MOVE " + llDumpList2String([ vThisPos, rThisRot ], "|"));
                        return;
                }
 
                //////////////////////////////////////////////////////////////////////////////////////////
                if( sText == "MOVE" )
                {
                        llOwnerSay("Positioning");
                        vector vThisPos = llGetPos();
                        rotation rThisRot = llGetRot();
                        llShout(PRIMCHAN, "MOVE " + llDumpList2String([ vThisPos, rThisRot ], "|"));
                        return;
                }
 
                //////////////////////////////////////////////////////////////////////////////////////////
                if( sText == "CLEAN" )
                {
                        llShout(PRIMCHAN, "CLEAN");
                        return;
                }
 
                //////////////////////////////////////////////////////////////////////////////////////////
                if( sText == "DONE" )
                {
                        llShout(PRIMCHAN, "DONE");
                        //llDie();
                        llOwnerSay("Removing mover scripts.");
                        return;
                }
        }
}
 
///////END BASE SCRIPT