Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

De-Rezzing an Object?

Persephone Milk
Very Persenickety!
Join date: 7 Oct 2004
Posts: 870
12-02-2004 22:12
Here is what I want to to:

I made a translucent cube. When you click on the cube several linked prim are rezzed inside the cube. When you click again, the objects disappear.

I have been able to get my object (3 linked prim) to appear after a click using llRezObject(). However, I do not know a way to delete these objects when the cube is clicked again.

What do I do?

Thanks,

Persephone Milk
Pedro Pendragon
Registered User
Join date: 15 Jan 2004
Posts: 77
12-02-2004 22:39
I would suggest having the prims inside change texture to a 100% alpha texture. This won't actually delete them, but make them invisible... Then to bring them back, just switch to the regular texture again.

If you really want to delete them, you can use the llDie() function. This will delete whatever object it's run on -- so to have object A delete object B, you actually would need A to send a message to B that says "please die now" and have B listen and call the llDie() itself.
Upshaw Underhill
Techno-Hobbit
Join date: 13 Mar 2003
Posts: 293
12-02-2004 22:44
Best bet is probably going to be a whisper from the cube on a private channel and a listen in the linked set listing on that private channel and doing an llDie() when it hears something (anything really if you choose a really high private channel)

L8r,
UU
Persephone Milk
Very Persenickety!
Join date: 7 Oct 2004
Posts: 870
12-02-2004 23:36
Thank you both.

I reached the same conclusion after studying the language manual. It's a shame the llRezObject call doesn't return a handle to the new object instance. It would be nice to call a member method of the instance to kill it, as in:

myInstance = llRezObject(...);
myInstance.die;

Oh well. I am just learning this language. Thanks again for your help.

Persephone Milk
Azelda Garcia
Azelda Garcia
Join date: 3 Nov 2003
Posts: 819
12-03-2004 03:26
Actually it does, but via an event :-/

The event is: object_rez( key objectkey ){ } (hmmm, might be rez_object actually, one or the other).

Azelda
_____________________
Persephone Milk
Very Persenickety!
Join date: 7 Oct 2004
Posts: 870
12-03-2004 06:34
Ah, well yes. But I cannot externally call a method of my instance. I was hoping that this language was a bit more object oriented - seems like a perfect application for pure object oriented design. In any event (pun intended) it's still quite a powerful language and I am having a ton of fun.

Thank you!

Persephone
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
12-03-2004 07:20
Welll.... there is another possibility here.

When you rez an object with llRezObject, the last parameter is an integer "param" for that object, which the newly rezzed object can get via llGetStartParameter() and in its "on_rez()" event. You could have the newly rezzed object then call llSetRemoteScriptAccessPin() using this parameter as the PIN.

This allows any external object to load a script, provided they know the PIN. Your rezzer could then load a script that simply contains llDie() in default/state_entry.

So you could have the following 3 code snippets. Lets call the two objects rezzer (the object that does the rezzing) and rezzee (the object that is rezzed)...

Code snippet for rezzer :
CODE

integer someMagicNumber; // global variable
key rezzedObjectKey; // global variable

...

// code that rezzes the object
llRezObject(objectName, objectPos, objectVel, someMagicNumber);

...

// event handler to get rezzed object's key
object_rez(key id)
{
rezzedObjectKey = id;
}

...

// code that kills the rezzee
llRemoteLoadScriptPin(rezzedObjectKey, "killer", someMagicNumber, TRUE, 0);


Code snippet for rezzee :
CODE

// this event handler will set the remote access PIN based on start parameter
on_rez(integer param)
{
llSetRemoteScriptAccessPin(param);
}


Code for "killer" script :
CODE

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


Its not quite as elegant as the C++ code you wrote, but except for the "on_rez()" event that you MUST have inside of rezzee somewhere to setup the PIN, this puts the onus on rezzor to manage everything.

- Ace
_____________________
"Free your mind, and your ass will follow" - George Clinton
Persephone Milk
Very Persenickety!
Join date: 7 Oct 2004
Posts: 870
12-03-2004 10:16
Thanks Ace. I like this solution. Seems cleaner and more direct than sending messages (though this still may be what happens behind the scenes).

I will give this a shot tonight. Thanks for your help!

Persephone