Jump to content

Having an Object "llDie" when it is away from a Main Build that Rezed it


Ralph Honi
 Share

You are about to reply to a thread that has been inactive for 4204 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I have secondary objects (peripherals) that are rezed by a main build but unlinked to the main build. I am trying to write scripts to have the peripherals delete themselves when the main build is deleted or moved away. The scripts I have written here do talk with each other … however the one that lives in the peripherals always sees the “Die” option. Looks like this; [08:58] Peripheral whispers: initial check [08:58] Main Build whispers: stay_rezzed [08:58] Peripheral whispers: I will stay rezzed [08:58] Peripheral whispers: I'm going to die [08:58] Main Build whispers: stay_rezzed [08:58] Peripheral whispers: I will stay rezzed [08:58] Peripheral whispers: I'm going to die I can’t have the Main Build tell the Peripherals that it isn’t there anymore … I’m having difficulty with the logic. I have also read that “llSleep” is better than a Timer so that is why I am using that. Since the Peripherals are not linked or attached to the Avatar … I am having difficulty filtering so that only the owners objects will communicate in case there is another Main Build in the nearby area performing the same queries. I am testing by having my AV near 2 Boxes with the scripts so I can "hear" the functions. Here are the Scripts; // Lives in the Main Object // Answers when queried integer CHNL26 = 216; // DeRez objects integer CHNL27 = 217; // DeRez objects default { state_entry() { // llListen(CHNL27, "", llGetOwner(), "" ); I need to look into this ... I think I have a solution llListen(CHNL27, "", NULL_KEY, "" ); } listen(integer channel, string name, key id, string message) { if(message == "checking?"); { llWhisper(CHNL26, "stay_rezzed"); llWhisper(0,"stay_rezzed"); } } } // Lives in the Peripheral Objects // Checks if the Main Build is still there // If not, then the periferals are deleted integer CHNL26 = 216; integer CHNL27 = 217; integer rezzed = FALSE; check_rez() { llWhisper(CHNL27, "checking?"); } default { state_entry() { // llListen(CHNL26, "", llGetOwner(), "" ); llListen(CHNL26, "", NULL_KEY, "" ); } on_rez(integer start_parameter) { check_rez(); // Will trigger the first Listen? llWhisper(0,"initial check"); } listen(integer channel, string name, key id, string message) { if(message == "stay_rezzed") { rezzed = TRUE; llWhisper(0,"I will stay rezzed"); llSleep(3.0); rezzed = FALSE; check_rez(); } if(rezzed == FALSE) // else if(rezzed == FALSE) { llWhisper(0,"I'm going to die"); // llDie(); } } }
Link to comment
Share on other sites

Oke, I can't quite make out the code you're using, but you seem to have the right idea. You're probably better off using a timer though. Also, as the wiki points out: Use a negative channel, preferably a large negative channel.

There are a few ways around the problem of having the same build nearby. If the main object rezzes the child objects, you can pass a random number to it, and use that one to communicate. You only need one channel for communication - objects cannot hear themselves anyway, they can only hear other objects.

Another way, if only "owner" is relevant, is to have a statement in the listen event like this:

listen(integer iChan, string sName, key kID, string sMessage) {    if(llGetOwnerKey(kID) == llGetOwner()) {        // This part will only execute if both objects have the same owner    }}

 

Link to comment
Share on other sites

I'm not gonna even try to read all you put there but what you appear to refer to is in computer world called "heartbeat". There is a device periodically sending a message and there are one or more others listening. If the message is received on time or within a certain time window, everything is fine. If it is not received (usually twice or three times in a row) then listening device does something (including dying). Usually the function checking for a heartbeat in the listening device is called "watchdog". There are standard language-independent implementation methods which you can google.

Link to comment
Share on other sites

  • 9 months later...

I had the same problem almost:

I have built a school and i want to llRezzObject desks fror the schools inventory unlinked so avatars can sit on them:

I rezz the desks from a llDialog Menu in the school script building script

One of the options on the llDialog menu is to clear the rezzed Objects

 

I created a llSensorReapeat in in the prim desks thats senses when a further hidden object has been rezzed near the desks.

 In the desks prim using llSensor llDies iteself  I rezz the hidden phantom tranparrent object called "Die" its a temp prim with a small script that llDies it after 10 seconds

 

Here is the code for prim or linked prims you want to delete that was llRezzObject from another object

 

Prim linked desks

default
{
state_entry()
{
llSensorRepeat("Die","",SCRIPTED | PASSIVE,5,PI,5.0);
}
sensor(integer num)
{

\\ you can and maybe should add an llSensorRemove(); here

llDie();
}

no_sensor()
  {
//add some debug code or sorthing else if not senced here

  }
}

Here is the code for the hidden object that delets itself after so many seconds

 

Hidden prim Die:

default
{
state_entry()
{
llSleep(10.0);
llDie();
}

}

:

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4204 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...