Difference between revisions of "Send vector as on rez param"

From Second Life Wiki
Jump to navigation Jump to search
m
(Blanked the page)
 
Line 1: Line 1:
Send a vector directly to a rezzed object via 'param' in on_rez(integer param)


<lsl>
//
// BETLOG Hax
// UTC10: 20090606 2252 [SLT:  20090606 0552]
// * Rez an object and pass a position vector directly to it via the rez integer parameter
// * vector is only accurate to nearest meter, and range limited by l+=l warppos method AND number of digits (10) in the start param
//
// caveats:
// Compare MAX_INT
// 2147483647
// with the far corner of a sim
// 2562564096
// ...obviously an x value of 214m is as far as this method will reach without some further trickery
// (trickery not included here)
//=========================================================================
// ---LICENCE START---
// http://creativecommons.org/licenses/by-sa/3.0/
// ie: Attribution licence:
//  Give me credit by leaving it in the script I created.
//  Supply my original script with your modified version.
//  Refer to the wiki URL from which you copied this script.
//      https://wiki.secondlife.com/wiki/Send_vector_as_on_rez_param
// ---LICENCE END---
//=========================================================================
// SHARED CONFIGURATION
//----------------------------------
// CONFIGURATION
//----------------------------------
// CORE CODE
//----------------------------------
f_deploy(key target)
{  if(llGetAgentSize(target)!= ZERO_VECTOR)
    {  vector pos = llList2Vector(llGetObjectDetails(target, ([OBJECT_POS])),0);
        string X=(string)llRound(pos.x);
                while(llStringLength(X)<3) //moot really, because leading 0's get stripped by typecasting
                    X="0"+X;
        string Y=(string)llRound(pos.y);
                while(llStringLength(Y)<3)
                    Y="0"+Y;
        string Z=(string)llRound(pos.z);
                while(llStringLength(Z)<4)
                    Z="0"+Z;
        llRezObject(
            llGetInventoryName(INVENTORY_OBJECT, 0)//OBJECT THAT CONTAINS THE OTHER SCRIPT BELOW
            , llGetPos()
            , ZERO_VECTOR
            , ZERO_ROTATION
            , (integer)(X+Y+Z)
        );
    }
}
//=========================================================================
default
{  touch_start(integer num)
    {  f_deploy(llDetectedKey(0)); //NO i would NOT normally be using in a touch event. It's just for a simple example.
    }
}
//=========================================================================
</lsl>
<lsl>
//
// BETLOG Hax
// UTC10: 20090606 2252 [SLT:  20090606 0552]
// * Receive a position vector directly via the rez integer parameter from the object rezzing me
// * vector is only accurate to nearest meter, and range limited by l+=l warppos method AND number of digits (10) in the start param
//=========================================================================
// ---LICENCE START---
// http://creativecommons.org/licenses/by-sa/3.0/
// ie: Attribution licence:
//  Give me credit by leaving it in the script I created.
//  Supply my original script with your modified version.
//  Refer to the wiki URL from which you copied this script.
//      https://wiki.secondlife.com/wiki/Send_vector_as_on_rez_param
// ---LICENCE END---
//=========================================================================
// SHARED CONFIGURATION
//----------------------------------
// CONFIGURATION
//----------------------------------
// CORE CODE
//----------------------------------
default
{  on_rez(integer param)
    {  if(param)//>0 is assumed
        {  string s = (string)param;
            while(llStringLength(s)<10)
                s="0"+s;
            list l=[PRIM_POSITION,<(float)llGetSubString(s,0, 2),(float)llGetSubString(s,3, 5),(float)llGetSubString(s,6, 9)>];
            l+=l;l+=l;l+=l;l+=l;l+=l;l+=l;l+=l;l+=l;l+=l; //Thanks Moy
            //20,40,80,160,320,640,1280,2560,5120 //not *actually* from <0,0,0> to <256,256,4096>... but still a long way in one jump
            llSetPrimitiveParams(l);
            llTriggerSound("55a5c332-9303-8057-61eb-657ef571ab5e", 1.0); //PingSplash
        }
    }
}
//=========================================================================
</lsl>
[[Category:LSL Examples]]

Latest revision as of 13:34, 17 August 2009