Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Object Dies when Owner is not Near

Johnny Mann
Registered User
Join date: 1 Oct 2005
Posts: 202
05-08-2006 14:25
Hi I was wondering if anyone can point me in the right direction. I am looking for a simlple way to make an object die when im not near. I was thinking of making a pet with a script I've been working on but I wanna reduce all letter by utilizing llDie() after a set time.


I'm assuming sensors come into play just don't know that much about them at the moment.

Thanks
Tip Baker
Registered User
Join date: 12 Nov 2005
Posts: 100
05-08-2006 14:56
CODE

float range = 10;
default
{
state_entry()
{
llSensorRepeat("",llGetOwner,AGENT,range,PI,5);
}
no_sensor()
{
llDie();
}
}


Should do the trick
Johnny Mann
Registered User
Join date: 1 Oct 2005
Posts: 202
05-08-2006 15:44
From: Tip Baker
CODE

float range = 10;
default
{
state_entry()
{
llSensorRepeat("",llGetOwner,AGENT,range,PI,5);
}
no_sensor()
{
llDie();
}
}


Should do the trick



Perfect Thanks.

There is one thing. The llGetOwner needs the () after it. I know a bit of scripting so easy to figure out. I fixed it for the Newbs below.

float range = 10;
default
{
state_entry()
{
llSensorRepeat("",llGetOwner(),AGENT,range,PI,5);
}
no_sensor()
{
llDie();
}
}
Nepenthes Ixchel
Broadly Offended.
Join date: 6 Dec 2005
Posts: 696
05-08-2006 16:42
Does the polling really need to be every 5 seconds? Unless it's critical the pte pies quickly I'd reduce it to every 30 seconds, or maybe even every minute.
Travis Lambert
White dog, red collar
Join date: 3 Jun 2004
Posts: 2,819
05-08-2006 19:25
If you're using this for a follow pet, be careful when using the llSensor() method across sim boundaries.

Due to current features/bugs, if you are in one sim, your pet is in another, and the sensor fires at that very moment you're crossing: its theoretically possible your pet will return the no_sensor event, and llDie() itself :(
_____________________
------------------
The Shelter

The Shelter is a non-profit recreation center for new residents, and supporters of new residents. Our goal is to provide a positive & supportive social environment for those looking for one in our overwhelming world.
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
05-08-2006 19:32
From: Travis Lambert
Due to current features/bugs, if you are in one sim, your pet is in another, and the sensor fires at that very moment you're crossing: its theoretically possible your pet will return the no_sensor event, and llDie() itself :(

Guess more of the reason to make the delay between sensor pings longer, and maybe add an extra safety check.... something like a flag that gets set when the sensor sweep turns out empty, and then making the object die only when both most current sensor check fails _and_ the flag for the previous check indicates the same. Together should grant enough time for the pet to sync with owner again if it was just occasional glitch.
Kokiri Saarinen
Quoted for truth
Join date: 7 Jan 2006
Posts: 44
05-09-2006 18:47
I usually just set a timer on no_sensor, and on that time expiration it dies. If the owner is sensed again within the time limit, it turns off the timer ^^
Catfart Grayson
Registered User
Join date: 16 May 2004
Posts: 264
05-10-2006 11:27
From: Travis Lambert
If you're using this for a follow pet, be careful when using the llSensor() method across sim boundaries.

Due to current features/bugs, if you are in one sim, your pet is in another, and the sensor fires at that very moment you're crossing: its theoretically possible your pet will return the no_sensor event, and llDie() itself :(


I agree about the problem, but not the cause or solution.

I think that object data from near(adjacent) servers is only sent once every five seconds and is only available to sensors for about a second. Design or bug, I'm not sure.

The upshot is that a sensor will only detect an object in a near sim if it fires during the short window of time that the data is available.

I tested this with llSensorRepeat at a variety of speeds;
A sensor rate slower than 5 seconds will only sporadically detect objects in near sims.
Sensor rates of 0.25 seconds detect objects approximately one time in twenty.
Sensor rates of one second detect objects every fourth to sixth time.

I didnt test llSensor with a timer, and didnt test sim crossing because I had'nt found that to be a problem.

I have a repeat rate of 1 per second. During no_sensor events I run a count, if it hasnt been reset by the sensor event for 20 sweeps ( = 20 seconds, = 4 near sim sweeps), the robot assumes that the target has gone.

During the other no_sensor events, the robot estimates the position based on the last known position and velocity.

Most of the time, the last known position is just inside the robot's sim, because in the next second the target has moved into the near sim, and doesnt appear on the next sensor sweep. By the time the robot has estimated a position and moved towards it, its moved into the same sim as the target and the problem has gone.

That method works for me upto velocities of about 5 meters a second.

Now corners I havnt bothered to figure, too many other problems to make it worth while. I assume the diagonal sim counts as a near sim, but havnt tested it.
_____________________
Cat
Kim Anubis
The Magician
Join date: 3 Jun 2004
Posts: 921
05-10-2006 11:39
OMG, Cat! *jumps up and down and waves* Long time no see!
_____________________
http://www.TheMagicians.us
Tip Baker
Registered User
Join date: 12 Nov 2005
Posts: 100
05-10-2006 12:24
From: Kim Anubis
OMG, Cat! *jumps up and down and waves* Long time no see!


Hey Kim, how you doing?

Sort of half back at the moment. I may see you online sometime.
Tip Baker
Registered User
Join date: 12 Nov 2005
Posts: 100
05-10-2006 12:25
From: Tip Baker
Hey Kim, how you doing?

Sort of half back at the moment. I may see you online sometime.

lol, well thats one way to blow an alt
Merlin Alphabeta
Registered User
Join date: 12 Feb 2006
Posts: 83
Techniques I use
05-11-2006 08:32
I run a petshop in Bowfin.

First off, I limit my sensor scan to once every 60 seconds. For "useless" entertainment objects, a 1 sec or 5 sec scan is ridiculous.

Doing 20 1 sec scans in a row just to cross the sim boundary is even MORE ridiculous. That might be an appropriate use of resources for a PDA or defense bot or something with some piece of critical utility - but for a pet it just doesn't make sense...

I die on the first no_sensor event I get. I fixed this problem in a slightly less elegant (but far less resource intensive) manner.

I sell an auto-rezzing bracelet for my pets. You get it, you put your pets in (any object will work!), and when you cross the sim boundary, it re-rezzes the pet for you. This works also on teleports and fast moving in-sim elevators and lost and found returns and any other situation of the sort...

I would recommend you build your own (or just buy one of mine - they're $250L and will work for anything you want to autorez - search for Merlin's Tower or just Merlin to find it) and do it that way, a lot more useful and less resource-intensive. Mine has a lot of added utility and a nice interface, but fundamentally all you need to do is a sensor sweep for the object's name and on a no_sensor call llRezObject...