Jump to content

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


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

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

Recommended Posts

Sorry about thall this not having a good day ...

Hopefully this works

I have secondary objects (peripherals) that are rezzed 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 post
Share on other sites

Duplicate post to http://community.secondlife.com/t5/LSL-Scripting/Having-an-Object-quot-llDie-quot-when-it-is-away-from-a-Main/m-p/1337749/message-uid/1337749#U1337749.  Replies in that thread

This one's just Ralph trying to get the formatting right *grin*/  PS: There is no need to start a new thread, you can just make a new post in the other one (or use Options > Edit to change the OP)

Link to post
Share on other sites

And here's the second one ...

 

// Lives in the Peripheral Objects// Checks if the Main Build is still there// If not, then the periferals are deletedinteger 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();		}	}}

 

The problem is that you set rezzed to FALSE before calling check_rez() and although another listen event will be generated it can't be handled until you've finished with the current one ... which promptly kills the thing.  (Solution follows ...)

Link to post
Share on other sites

Try this - the checking and suicide are controlled by the timer.  The peripheral starts off rezzed = TRUE, checks the parent every 3 seconds and sets rezzed = FALSE.  If a reply is received in time it will continue in this cycle, setting rezzed = TRUE again.  Otherwise the timer will (finally) see rezzed = FALSE and will suicide.

 

// Lives in the Peripheral Objects// Checks if the Main Build is still there// If not, then the periferals are deletedinteger CHNL26 = 216;integer CHNL27 = 217;integer rezzed = TRUE;default {	state_entry() {		// llListen(CHNL26, "", llGetOwner(), "" );		llListen(CHNL26, "", NULL_KEY, "" );		llSetTimerEvent(3.0);	}	listen(integer channel, string name, key id, string message) {		if(message == "stay_rezzed") {			llWhisper(0,"I will stay rezzed");			rezzed = TRUE;		}	}	timer(){		if(rezzed){			llWhisper(CHNL27, "checking?");			rezzed = FALSE;		}else{			llWhisper(0, "I'm going to die");			llDie();		}	}}

 

Link to post
Share on other sites

Works Great!  thanks a million.

I understand now ... the way I had it .. TRUE was never seen. 

I am using only one channel now (was thinking it was hearing itself) now will revise the code to listen to "owner" only

Thanks again everyone

 

Link to post
Share on other sites
You are about to reply to a thread that has been inactive for 3397 days.

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...