| Scripting Discuss scripting for SL and other platforms |
| |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #2 (permalink) |
| Junior Member ![]() Join Date: Jul 2009
Posts: 9
| Do you want it to be physical or non-physical? If it is non-physical it is fairly straightforward. If it is physical it can be done but there are a number of different ways to do it with varying degrees of difficulty and how nice it looks. I have scripts to do the physical movement. Non-physical movement is fairly straightforward. Get the uuid of the object that you want to follow and then set a timer. You can then use llGetObjectDescription, LlGetObjectDetails - Second Life Wiki to get the position and rotation of the object. Then use llSetPrimitiveParams, LlSetPrimitiveParams - Second Life Wiki to set the position and rotation in one function call. |
| | |
| | #4 (permalink) |
| The Purple ![]() ![]() ![]() ![]()
Kinda at work. Somewhat.
Join Date: Dec 2007 Location: Somewhere purple, Germany
Posts: 3,096
My Mood: | Code: integer iListener;
key kOwner;
string sTarget;
key kTarget;
vector vTemp;
list rules;
integer count;
integer jumps;
warpPos( vector destpos )
{ //R&D by Keknehv Psaltery, 05/25/2006
//with a little poking by Strife, and a bit more
//some more munging by Talarus Luan
//Final cleanup by Keknehv Psaltery
//Changed jump value to 411 (4096 ceiling) by Jesse Barnett
// Compute the number of jumps necessary
jumps = (integer)(llVecDist(destpos, llGetPos()) / 10.0) + 1;
// Try and avoid stack/heap collisions
if (jumps > 411)
jumps = 411;
rules = [ PRIM_POSITION, destpos ]; //The start for the rules list
count = 1;
while ( ( count = count << 1 ) < jumps)
rules = (rules=[]) + rules + rules; //should tighten memory use.
llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, count) );
if ( llVecDist( llGetPos(), destpos ) > .001 ) //Failsafe
while ( --jumps )
llSetPos( destpos );
}
default
{
state_entry()
{
kTarget=NULL_KEY;
iListener=llListen(123,"",kOwner=llGetOwner(),"");
}
on_rez(integer foo)
{
if(kOwner!=llGetOwner())
{
llListenRemove(iListener);
iListener=llListen(123,"",kOwner=llGetOwner(),"");
}
}
listen(integer channel, string name, key id, string message)
{
sTarget=message;
llSensor("","",ACTIVE,96,PI);
}
no_sensor()
{
llOwnerSay("Specified object not found: "+sTarget);
}
sensor(integer foo)
{
do
{
if(!(llDetectedType(foo=~-foo) & AGENT))
if(llDetectedOwner(foo) == kOwner)
if(llSubStringIndex(llToLower(llDetectedName(foo)),llToLower(sTarget)) != -1)
{
kTarget=llDetectedKey(foo);
jump found;
}
}
while(foo);
@found;
if(kTarget != NULL_KEY)
{
llOwnerSay("Target found: "+llDetectedName(foo)+", following.");
llListenRemove(iListener);
llSetTimerEvent(0.01);
}
else
llOwnerSay("Specified object not found: "+sTarget);
}
timer()
{
if(llGetAgentSize(kOwner)
{
if(vTemp=(llList2Vector(llGetObjectDetails(kTarget,[OBJECT_POS]),0)) != ZERO_VECTOR);
warpPos(vTemp);
else
{
llOwnerSay("Target vanished. Returning.");
llSetTimerEvent(0);
warpPos(llList2Vector(llGetObjectDetails(kOwner,[OBJECT_POS]),0));
kTarget=NULL_KEY;
iListener=llListen(123,"",kOwner,"");
}
}
else
{
llOwnerSay("Owner vanished. Dieing.");
llDie();
}
}
}
__________________ "Have you ever noticed that anybody driving slower than you is an idiot, and anyone going faster than you is a maniac?" - George Carlin Last edited by Chalice Yao; 10-30-2009 at 04:58 AM. |
| | |
| | #6 (permalink) |
| The Purple ![]() ![]() ![]() ![]()
Kinda at work. Somewhat.
Join Date: Dec 2007 Location: Somewhere purple, Germany
Posts: 3,096
My Mood: | Fixed, was a missing closing brace of the warppos function. Sorry for that, I notoriously write full scripts here while not being able to log into SL at the time of the day ;P Also, you say object 1 should follow object 2 immediately after rez. What -is- object 2, i.e. what should it be looking out for? What name? I presume both are your objects. |
| | |
![]() |
| Thread Tools | |
| Display Modes | |
| |