Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Getting a lost object back

Paladin Pinion
The other one of 10
Join date: 3 Aug 2007
Posts: 191
03-07-2008 14:32
While I'm learning about position and rotation, sometimes my test objects get away from me. For example, one time I mistyped a decimal point and my cube went off into the ether instead of moving a short way across the room. Another time I reset a script after making my cube physical, forgetting about gravity, and it went right through the floor of my treehouse and landed somewhere in a river. I have an object locator but if the object goes too far away, the locator doesn't see it. And objects are hard to find even if you do know their x,y,z coordinates.

So I was wondering how others deal with this. Do you put in scripts that bring it back? Or do you make it listen on a private channel and hope you are close enough for it to hear you? Or what? Any good tricks?

I know I could set it to die at the region's edge, but it often doesn't stray that far, and anyway, I usually don't want to kill it, I want it back.
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
03-07-2008 15:36
try using a beacon this script is set up for hours but you could mess with the times if you feel like your doing good in math ;)

this is time part "integer hours = 24;" it will send a instant message every X ammount of hours or whatever you put in so if it gets away it will tell you its location if you cont find it

CODE

integer hours = 24; // Number of hours between beacon IMs. Change this to suit your needs.


//No need to change anything below this line (unless you really want to)


integer active = TRUE;
integer currentHours;

beaconStatus()
{
if (active)
{
llInstantMessage(llGetOwner(),"Beacon is ON. Message interval set to " + (string)hours + ". Next message in less than "+ (string)(hours - currentHours) + " hours. Hours elapsed since last message: " + (string)currentHours + ".");
}
else
{
llInstantMessage(llGetOwner(),"Beacon is OFF. Message interval set to " + (string)hours + ". You will not be messaged.");
}
}

init()
{
currentHours = 0;
if (active) {llSetTimerEvent(3600);}
}

default
{
state_entry()
{
init();
}

on_rez(integer num)
{
init();
}

link_message(integer sender_num, integer num, string str, key id)
{
string message = llToLower(str);

// Listening for message to turn on or off.
if (message == "tc beacon off")
{
active = FALSE;
llSetTimerEvent(0.0);
beaconStatus();
}
else if (message == "tc beacon on")
{
active = TRUE;
currentHours = 0;
llSetTimerEvent(3600); // 1 hour timer?
beaconStatus();
}

// To set the beacon interval from an external script, send the link message
// "beacon interval" and send the number of hours as an integer.
else if (message == "tc beacon interval")
{
hours = num;
currentHours = 0;
beaconStatus();
}

else if (message == "tc beacon status")
{
beaconStatus();
}
}

timer()
{
if (active)
{
currentHours += 1;
if (currentHours == hours)
{
vector pos = llGetPos();
llInstantMessage(llGetOwner(),"Locator beacon: Your vehicle is located at " + llGetRegionName() + "(" + (string)llRound(pos.x)+","+(string)llRound(pos.y)+") at an altitude of " + (string)llRound(pos.z) + " meters.");
currentHours = 0;
}
}
}
}
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
03-07-2008 17:06
there's also status retun at edge, but I thought that was default behavior.....

assuming it ends up on scripted land (or above ~70 over the ground) you could add a sensor and timer to check if you are around (for testing purposes) then set physics and phantom and drop it off world (in which case it should be returned to your lost and found after a minute or so) another possibility is to make it temp on rez, but this requires you be sitting on it to keep it alive, in which case you SHOULD go where it goes.... although with a quirky sim crossing that's no guarantee... and it dies instead of coming back.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Paladin Pinion
The other one of 10
Join date: 3 Aug 2007
Posts: 191
03-07-2008 17:53
From: Void Singer
there's also status retun at edge, but I thought that was default behavior.....


Apparently so, since I just got an object back that way. :) Usually they don't stray that far.

The beacon idea is interesting, I may try it, though what I'm thinking about now is something of a combination between the two suggestions. Maybe run a scan every few minutes and if I'm not within a certain range, have the object toddle back to me.
Lost Oddfellow
Registered User
Join date: 15 Sep 2005
Posts: 33
03-08-2008 00:28
if you only test one or two objects at a time you can use sensors.
I use a script that checks for me within 25.000 units of distance and if it doesn't find me the object either dies right away or begins informing me of it's location every minute (if it's location changes) for an hour and then dies
_____________________
I've made my statement and I stand by it,
but I could be wrong.
Paladin Pinion
The other one of 10
Join date: 3 Aug 2007
Posts: 191
03-08-2008 14:53
Here's what I settled on, in case anyone needs something similar. This will cause the object to come back to you if it gets away:

// Paladin Pinion, March 2008
// Put this into the root prim of an object. If it roams too far, it will come
// back if the object is still in the same sim as you are. If it has gone outside
// the sim, auto-return will send it back to your Lost and Found instead.

float gRange = 5.0; // allowable range, in meters, until object comes back


reset()
{
llSetTimerEvent(30); // half minute checks
}
default
{
state_entry()
{
reset();
}

on_rez(integer startup_param)
{
reset();
}

timer()
{
vector objPos = llGetPos();
vector ownerPos = llList2Vector(llGetObjectDetails(llGetOwner(),[OBJECT_POS]),0);
if (llVecDist(objPos,ownerPos) > gRange)
{
llOwnerSay("Starting movement";);
integer physical = llGetStatus(STATUS_PHYSICS);
llSetStatus(STATUS_PHYSICS,FALSE);
while (llVecDist(llGetPos(),ownerPos) > 2.0) llSetPos(ownerPos + <0.5,0.5,0>;); // so it doesn't land on you
if (physical == TRUE) llSetStatus(STATUS_PHYSICS,TRUE);
llOwnerSay(llGetObjectName() + " has moved to " + (string) llGetPos());
}
}
}


One thing I don't understand. If I have a nonphysical object and I change it to physical, it drops right through the floor. But after it comes back, SL seems to recognize it as physical and I can roll it around or drop it forever after that, and it stays on the floor. What's with that?
Paladin Pinion
The other one of 10
Join date: 3 Aug 2007
Posts: 191
Where am I when I'm not there?
03-09-2008 19:46
The script I posted worked fine all day until my client froze. I had to force-quit and relog. Of course, while I was gone, my practice prim missed me and went looking to find me. The way the script was written, it wouldn't have noticed my absence until I was actually offline. So now the prim is lost, and I don't know where it is. It was not returned to inventory, so I assume it is somewhere on the sim, but I can't find it.

Does anyone know what location SL sends back if an avator is offline? Because my prim is in a loop, trying to get there.