These are those "sit & go" type prim based teleporters that you might use to get from the ground to a skybox (or similar). It uses a function that uses almost no memory compared with and as opposed to another popular function performing a similar task.
- Add the destination as a comma separated string of three numbers to the description of the prim the script is in (ideally the root).
- https://d1yjxggot69855.cloudfront.net/skins/monobook/bullet.gif); ">
- E.g. 36,128,4000.5
- The numbers represent the X,Y and Z coordinates of the destination on the region the scripted object is on.
When you sit on the object the operation happens automatically.
- Thanks to Strife Onizuka for helping improve this function (and my knowledge).
- Temp Rez Version ( V7 )
This version is a one way, self deleting type. E.g. An object containing this script could be rezzed by a sign when touched allowing visitors to use the rezzed teleporter to be taken directly to areas of a region/parcel. Since the sign could be just 1 prim providing multiple destinations and each rezzed teleporter is both temporary and phantom the savings on both prim count and server stress
are obvious.
// V7 //
Zippadeedoodah(vector dest) // Feed in the destination vector.
{
integer l_num = (!!llGetLinkNumber()); // Establish the link number of the root.
list params = [6, dest]; // Create the parameters for llSetPrimParamsFast.
// Loop while the distance between the root and dest is greater than 0.001 meter.
while(llVecDist(llGetRootPosition(), dest) > 0.001)
llSetLinkPrimitiveParamsFast(l_num, params); // Each iteration attempt to move to dest.
}
default
{
on_rez(integer param)
{
llSetClickAction(CLICK_ACTION_SIT); // Makes the prim "Click to sit".
llSetLinkPrimitiveParamsFast(-1, [PRIM_TEMP_ON_REZ, TRUE, // Make the object temporary.
PRIM_PHANTOM, TRUE]); // And phantom.
// Makes the object less intensive for the region. Also makes a smoother llUnSit.
}
changed(integer change)
{
if(change & CHANGED_LINK) // If an avatar sits on the object they become one of the links.
{
integer links = 0; // Create an integer type variable
if(llGetObjectPrimCount(llGetKey()) < (links = llGetNumberOfPrims())) // Check if there are more links than prims.
{
llSetLinkPrimitiveParamsFast(-1, [PRIM_TEMP_ON_REZ, TRUE]); // Make the object temporary.
Zippadeedoodah(((vector)("<" + llGetObjectDesc() + ">"))); // Call the function to transport us.
llUnSit(llGetLinkKey(links)); // When we arrive, Un-Sit the key that is not a prim.
llDie(); // Delete the object.
}
}
}
}
Permanent Version ( V9 )
This version drops the user off at the destination then either waits for the set time or goes straight back home to be reused.
// V9 //
float time = 3600.0; // The time in seconds to wait before returning to home position.
// If set to zero, the return home for the object will be immediate.
/////////////////////////////////////////////////////////////////////////////////////////
Zippadeedoodah(vector dest) // Feed in the destination vector.
{
integer l_num = (!!llGetLinkNumber()); // Establish the link number of the root.
list params = [6, dest]; // Create the parameters for llSetPrimParamsFast.
// Loop while the distance between the root and dest is greater than 0.001 meter.
while(llVecDist(llGetRootPosition(), dest) > 0.001)
llSetLinkPrimitiveParamsFast(l_num, params); // Each iteration attempt to move to dest.
}
vector home; // Used to store the home position.
default
{
state_entry()
{
home = llGetRootPosition(); // Establish where our home pos is.
// For this reason, Reset the script when the home position of the object is chosen.
llSetClickAction(CLICK_ACTION_SIT); // Makes the prim "Click to sit".
llSetStatus(STATUS_PHANTOM, TRUE); // Makes the object less intensive for the region.
} // Also makes a smoother llUnSit.
changed(integer change)
{
if(change & CHANGED_LINK) // If an avatar sits on the object they become one of the links.
{
integer links = 0; // Create an integer type variable
if(llGetObjectPrimCount(llGetKey()) < (links = llGetNumberOfPrims())) // Check if there are more links than prims.
{
vector Dest; // Create a vector type variable.
if(llVecDist(llGetRootPosition(), (Dest = ((vector)("<" + llGetObjectDesc() + ">")))) > 0.0015)
{ // Check if the object is near destination. If not, go there.
Zippadeedoodah(Dest); // Call the function to transport us.
llUnSit(llGetLinkKey(links)); // When we arrive, Un-Sit the key that is not a prim.
if(((integer)time))
llSetTimerEvent(time); // Start a timer.
else
Zippadeedoodah(home); // Go back home.
}
else
llUnSit(llGetLinkKey(links)); // Un-Sit the key that is not a prim.
}
}
}
timer()
{
llSetTimerEvent(0.0); // Cancel the timer.
Zippadeedoodah(home); // Go back home.
}
}